Skip to content

Commit 7cc1988

Browse files
authored
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
1 parent 47da34c commit 7cc1988

File tree

5 files changed

+79
-1
lines changed

5 files changed

+79
-1
lines changed

Dockerfile.dev

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Requires the root repo dir to be mounted at /mnt/go-ethereum in order to run this!
2+
FROM golang:1.14-alpine
3+
4+
RUN apk add --no-cache make gcc musl-dev linux-headers git
5+
RUN apk add --no-cache ca-certificates
6+
7+
EXPOSE 8545 8546 8547 30303 30303/udp
8+
9+
# Used to mount the code so image isn't re-built every time code changes
10+
WORKDIR /mnt/go-ethereum
11+
12+
ENTRYPOINT ["sh", "./docker/dev_entrypoint.sh"]

docker-compose.dev.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: "3"
2+
3+
services:
4+
geth_l2:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile.dev
8+
volumes:
9+
- l2-node-data:/mnt/l2-node/l2:rw
10+
- ./:/mnt/go-ethereum/
11+
12+
environment:
13+
- REBUILD= # Set this if you want to rebuild on startup, leave unset otherwise
14+
- CLEAR_DATA_KEY
15+
- TARGET_GAS_LIMIT
16+
- VOLUME_PATH=/mnt/l2-node/l2
17+
- HOSTNAME=geth_l2
18+
- PORT=8545
19+
- NETWORK_ID=108
20+
ports:
21+
- 8545:8545
22+
23+
volumes:
24+
l2-node-data:

docker/dev_entrypoint.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# Exits if any command fails
4+
set -e
5+
6+
if [ -n "$REBUILD" ]; then
7+
echo -e "\n\nREBUILD env var set, rebuilding...\n\n"
8+
9+
make geth
10+
echo -e "\n\nCode built proceeding with ./entrypoint.sh...\n\n"
11+
else
12+
echo -e "\n\nREBUILD env var not set, calling ./entrypoint.sh without building...\n\n"
13+
fi
14+
15+
echo "Starting Geth..."
16+
## Command to kick off geth
17+
TARGET_GAS_LIMIT=${TARGET_GAS_LIMIT:-4294967295}
18+
./build/bin/geth --dev \
19+
--datadir $VOLUME_PATH \
20+
--rpc \
21+
--rpcaddr $HOSTNAME \
22+
--rpcvhosts='*' \
23+
--rpcport $PORT \
24+
--networkid $NETWORK_ID \
25+
--rpcapi 'eth,net' \
26+
--gasprice '0' \
27+
--targetgaslimit $TARGET_GAS_LIMIT \
28+
--nousb \
29+
--gcmode=archive \
30+
--verbosity "6"

docker/entrypoint.sh

100644100755
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,16 @@ fi
1818

1919
echo "Starting Geth..."
2020
## Command to kick off geth
21-
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"
21+
geth --dev \
22+
--datadir $VOLUME_PATH \
23+
--rpc \
24+
--rpcaddr $HOSTNAME \
25+
--rpcvhosts='*' \
26+
--rpcport $PORT \
27+
--networkid $NETWORK_ID \
28+
--rpcapi 'eth,net' \
29+
--gasprice '0' \
30+
--targetgaslimit $TARGET_GAS_LIMIT \
31+
--nousb \
32+
--gcmode=archive \
33+
--verbosity "6"

docker/test_entrypoint.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)