Create local development Dockerfile and docker-compose (#17)

Adding docker-compose.dev.yml and Dockerfile.dev to mount the current dir and call a script to conditionally build for fast iteration
This commit is contained in:
Will Meister 2020-08-28 09:13:38 -05:00 committed by GitHub
parent 47da34c139
commit 7cc1988962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 1 deletions

12
Dockerfile.dev Normal file
View File

@ -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
docker-compose.dev.yml Normal file
View File

@ -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
docker/dev_entrypoint.sh Executable file
View File

@ -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
docker/entrypoint.sh Normal file → Executable file
View File

@ -18,4 +18,16 @@ fi
echo "Starting Geth..." echo "Starting Geth..."
## Command to kick off 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"

0
docker/test_entrypoint.sh Normal file → Executable file
View File