diff --git a/containers/docker/swarm-alpine/Dockerfile b/containers/docker/swarm-alpine/Dockerfile new file mode 100644 index 0000000000..19d946700d --- /dev/null +++ b/containers/docker/swarm-alpine/Dockerfile @@ -0,0 +1,28 @@ +# Docker container spec for building the swarm branch of go-ethereum. +# +# The build process it potentially longer running but every effort was made to +# produce a very minimalistic container that can be reused many times without +# needing to constantly rebuild. +FROM alpine:3.3 + +# Build go-ethereum on the fly and delete all build tools afterwards +RUN \ + apk add --update go git make gcc musl-dev && \ + git clone https://github.com/ethersphere/go-ethereum && \ + (cd go-ethereum && git checkout s/sworm-rc3-update) && \ + (cd go-ethereum && make geth) && \ + cp go-ethereum/build/bin/geth /geth && \ + apk del go git make gcc musl-dev && \ + rm -rf /go-ethereum && rm -rf /var/cache/apk/* + +# Make sure bash and jq is available for easier wrapper implementation +RUN apk add --update bash jq + +# Inject the startup script +ADD swarm.sh /swarm.sh +RUN chmod +x /swarm.sh + +# Export the usual networking ports to allow outside access to the node +EXPOSE 8545 8546 30303 + +ENTRYPOINT ["/swarm.sh"] diff --git a/containers/docker/swarm-alpine/swarm.sh b/containers/docker/swarm-alpine/swarm.sh new file mode 100644 index 0000000000..8e4ab0e36a --- /dev/null +++ b/containers/docker/swarm-alpine/swarm.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Startup script to initialize and boot a go-ethereum instance as a swarm node. +# +# This script assumes the following files: +# - `geth` binary is located in the filesystem root +# - `genesis.json` file is located in the filesystem root + +# Immediately abort the script on any error encountered +set -e + +if [ "$SWARM_NETWORK_ID" = "" ]; then export SWARM_NETWORK_ID=322; fi + +if [ ! -f "/swarm/data/nodekey" ]; then + # First run + echo "Initializing swarm node..." + mkdir -p /swarm/data + mkdir -p /swarm/enodes + mkdir -p /swarm/pids + /geth --datadir=/swarm/data --password=<(echo -n) account new +fi + +/geth --dev \ + --maxpeers=40 \ + --shh=false \ + --networkid=$SWARM_NETWORK_ID \ + --bzznoswap \ + --verbosity=6 \ + --vmodule=swarm/*=5,discover=5 \ + --datadir=/swarm/data \ + --bzzaccount=0 \ + --unlock=0 \ + --port=30303 \ + --bzzport=32200 \ + --nat=none \ + --rpc \ + --rpcaddr="0.0.0.0" \ + --rpccorsdomain="*" \ + --password=<(echo -n) \ + $*