From 0d092cc535996725df614b11dd120cc4c7325a0b Mon Sep 17 00:00:00 2001 From: srwadleigh <7832+srwadleigh@users.noreply.github.com> Date: Thu, 21 Oct 2021 19:02:22 +0000 Subject: [PATCH 1/2] add sudo and user permissions to Dockerfile, update startup_script.sh with overlay commands --- Dockerfile | 7 ++++++- startup_script.sh | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 188d614..1f60077 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ RUN apk add busybox-extras # Get and build ipfs-blockchain-watcher ADD . /go/src/github.com/vulcanize/eth-statediff-service +#RUN git clone https://github.com/vulcanize/eth-statediff-service.git /go/src/github.com/vulcanize/eth-statediff-service + WORKDIR /go/src/github.com/vulcanize/eth-statediff-service RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o eth-statediff-service . @@ -15,7 +17,10 @@ FROM alpine ARG USER="vdm" ARG CONFIG_FILE="./environments/example.toml" ARG EXPOSE_PORT=8545 -RUN adduser -Du 5000 $USER + +RUN adduser -Du 5000 $USER adm +RUN adduser $USER adm; apk --no-cache add sudo; echo '%adm ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + WORKDIR /app RUN chown $USER /app USER $USER diff --git a/startup_script.sh b/startup_script.sh index 7588b39..1fcc44d 100644 --- a/startup_script.sh +++ b/startup_script.sh @@ -4,8 +4,17 @@ set -e set +x # Check the database variables are set -test $VDB_COMMAND +test "$VDB_COMMAND" set +e -echo "Running the statediff service" -./eth-statediff-service ${VDB_COMMAND} --config=config.toml +# docker must be run in privilaged mode for mounts to work +echo "Setting up /app/geth-rw overlayed /app/geth-ro" +mkdir -p /tmp/overlay && \ +sudo mount -t tmpfs tmpfs /tmp/overlay && \ +mkdir -p /tmp/overlay/upper && \ +mkdir -p /tmp/overlay/work && \ +mkdir -p /app/geth-rw && \ +sudo mount -t overlay overlay -o lowerdir=/app/geth-ro,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /app/geth-rw && \ + +echo "Running the statediff service" && \ +sudo ./eth-statediff-service "$VDB_COMMAND" --config=config.toml \ No newline at end of file From 66835c4c3ee7123e411a9dbd5ad5c5d644100a2d Mon Sep 17 00:00:00 2001 From: srwadleigh <7832+srwadleigh@users.noreply.github.com> Date: Thu, 21 Oct 2021 19:07:19 +0000 Subject: [PATCH 2/2] add trailing space to start script --- startup_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startup_script.sh b/startup_script.sh index 1fcc44d..cfd63cc 100644 --- a/startup_script.sh +++ b/startup_script.sh @@ -17,4 +17,4 @@ mkdir -p /app/geth-rw && \ sudo mount -t overlay overlay -o lowerdir=/app/geth-ro,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /app/geth-rw && \ echo "Running the statediff service" && \ -sudo ./eth-statediff-service "$VDB_COMMAND" --config=config.toml \ No newline at end of file +sudo ./eth-statediff-service "$VDB_COMMAND" --config=config.toml