diff --git a/Dockerfile b/Dockerfile index 65a9172..6d84a5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ ARG CONFIG_FILE="./environments/config.toml" ARG EXPOSE_PORT=8545 RUN adduser -Du 5000 $USER adm -RUN adduser $USER adm; apk --no-cache add sudo; echo '%adm ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +RUN adduser $USER adm; apk --no-cache add sudo bash; echo '%adm ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers WORKDIR /app RUN chown $USER /app diff --git a/startup_script.sh b/startup_script.sh index e129df6..d743ff5 100755 --- a/startup_script.sh +++ b/startup_script.sh @@ -1,12 +1,14 @@ -#!/bin/sh +#!/bin/bash # Exit if the variable tests fail set -e -set +x +set -o pipefail + +if [[ -n "$CERC_SCRIPT_DEBUG" ]]; then + set -x +fi # Check the database variables are set test "$VDB_COMMAND" -set +e - # docker must be run in privilaged mode for mounts to work echo "Setting up /app/geth-rw overlayed /app/geth-ro" @@ -15,14 +17,17 @@ 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 && \ +sudo mount -t overlay overlay -o lowerdir=/app/geth-ro,upperdir=/tmp/overlay/upper,workdir=/tmp/overlay/work /app/geth-rw START_TIME=`date -u +"%Y-%m-%dT%H:%M:%SZ"` - echo "Running the statediff service" && \ -sudo -E ./eth-statediff-service "$VDB_COMMAND" --config=config.toml $* -rc=$? - +if [[ ! -z "$LOG_FILE_PATH" ]]; then + sudo -E ./eth-statediff-service "$VDB_COMMAND" --config=config.toml $* |& tee ${LOG_FILE_PATH}.console + rc=$? +else + sudo -E ./eth-statediff-service "$VDB_COMMAND" --config=config.toml $* + rc=$? +fi STOP_TIME=`date -u +"%Y-%m-%dT%H:%M:%SZ"` if [ $rc -eq 0 ] && [ "$PRERUN_ONLY" == "true" ] && [ ! -z "$PRERUN_RANGE_START" ] && [ ! -z "$PRERUN_RANGE_STOP" ] && [ ! -z "$DATABASE_FILE_CSV_DIR" ] && [ "$DATABASE_FILE_MODE" == "csv" ]; then