Skip to content

Commit

Permalink
Create local development Dockerfile and docker-compose (ethereum#17)
Browse files Browse the repository at this point in the history
Adding docker-compose.dev.yml and Dockerfile.dev to mount the current dir and call a script to conditionally build for fast iteration
  • Loading branch information
willmeister authored Aug 28, 2020
1 parent 47da34c commit 7cc1988
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Requires the root repo dir to be mounted at /mnt/go-ethereum in order to run this!
FROM golang:1.14-alpine

RUN apk add --no-cache make gcc musl-dev linux-headers git
RUN apk add --no-cache ca-certificates

EXPOSE 8545 8546 8547 30303 30303/udp

# Used to mount the code so image isn't re-built every time code changes
WORKDIR /mnt/go-ethereum

ENTRYPOINT ["sh", "./docker/dev_entrypoint.sh"]
24 changes: 24 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3"

services:
geth_l2:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- l2-node-data:/mnt/l2-node/l2:rw
- ./:/mnt/go-ethereum/

environment:
- REBUILD= # Set this if you want to rebuild on startup, leave unset otherwise
- CLEAR_DATA_KEY
- TARGET_GAS_LIMIT
- VOLUME_PATH=/mnt/l2-node/l2
- HOSTNAME=geth_l2
- PORT=8545
- NETWORK_ID=108
ports:
- 8545:8545

volumes:
l2-node-data:
30 changes: 30 additions & 0 deletions docker/dev_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Exits if any command fails
set -e

if [ -n "$REBUILD" ]; then
echo -e "\n\nREBUILD env var set, rebuilding...\n\n"

make geth
echo -e "\n\nCode built proceeding with ./entrypoint.sh...\n\n"
else
echo -e "\n\nREBUILD env var not set, calling ./entrypoint.sh without building...\n\n"
fi

echo "Starting Geth..."
## Command to kick off geth
TARGET_GAS_LIMIT=${TARGET_GAS_LIMIT:-4294967295}
./build/bin/geth --dev \
--datadir $VOLUME_PATH \
--rpc \
--rpcaddr $HOSTNAME \
--rpcvhosts='*' \
--rpcport $PORT \
--networkid $NETWORK_ID \
--rpcapi 'eth,net' \
--gasprice '0' \
--targetgaslimit $TARGET_GAS_LIMIT \
--nousb \
--gcmode=archive \
--verbosity "6"
14 changes: 13 additions & 1 deletion docker/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@ fi

echo "Starting Geth..."
## Command to kick off geth
geth --dev --datadir $VOLUME_PATH --rpc --rpcaddr $HOSTNAME --rpcvhosts=* --rpcport $PORT --networkid $NETWORK_ID --rpcapi 'eth,net' --gasprice '0' --targetgaslimit $TARGET_GAS_LIMIT --nousb --gcmode=archive --verbosity "6"
geth --dev \
--datadir $VOLUME_PATH \
--rpc \
--rpcaddr $HOSTNAME \
--rpcvhosts='*' \
--rpcport $PORT \
--networkid $NETWORK_ID \
--rpcapi 'eth,net' \
--gasprice '0' \
--targetgaslimit $TARGET_GAS_LIMIT \
--nousb \
--gcmode=archive \
--verbosity "6"
Empty file modified docker/test_entrypoint.sh
100644 → 100755
Empty file.

0 comments on commit 7cc1988

Please sign in to comment.