diff --git a/server/Dockerfile b/server/Dockerfile index 2855cc0..7859eb4 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -1,7 +1,7 @@ # ------------------------------------------------------------------------------ # Build go-flare # ------------------------------------------------------------------------------ -FROM golang:1.18.5 AS flare +FROM golang:1.21 AS flare WORKDIR /app @@ -18,7 +18,7 @@ RUN cd avalanchego && \ # ------------------------------------------------------------------------------ # Build flare-rosetta # ------------------------------------------------------------------------------ -FROM golang:1.18.5 AS rosetta +FROM golang:1.21 AS rosetta ARG ROSETTA_SRC=https://github.com/flare-foundation/flare-rosetta/archive/refs/heads/main.zip ARG ROSETTA_SRC_ZIP_SUBFOLDER=flare-rosetta-main @@ -50,7 +50,7 @@ RUN \ # ------------------------------------------------------------------------------ # Target container for running the rosetta server # ------------------------------------------------------------------------------ -FROM ubuntu:20.04 +FROM ubuntu@sha256:340d9b015b194dc6e2a13938944e0d016e57b9679963fdeb9ce021daac430221 ENV DEBIAN_FRONTEND=noninteractive diff --git a/server/docker/entrypoint_main.sh b/server/docker/entrypoint_main.sh index 9ff2689..55a8c96 100644 --- a/server/docker/entrypoint_main.sh +++ b/server/docker/entrypoint_main.sh @@ -8,13 +8,20 @@ PID_ENTRYPOINT_FLARE="" function cleanup () { + if kill -0 "$PID_ENTRYPOINT_FLARE"; then + echo "Flare process detected as exited" + fi + + if kill -0 "$PID_ENTRYPOINT_ROSETTA"; then + echo "Rosetta process detected as exited" + fi + if [ ! -z "${PID_ENTRYPOINT_ROSETTA}" ]; then echo "Sending KILL to ROSETTA entrypoint (pid:${PID_ENTRYPOINT_ROSETTA})..."; kill -SIGINT ${PID_ENTRYPOINT_ROSETTA}; fi if [ ! -z "${PID_ENTRYPOINT_FLARE}" ]; then echo "Sending KILL to FLARE entrypoint (pid:${PID_ENTRYPOINT_FLARE})..."; kill -SIGINT ${PID_ENTRYPOINT_FLARE}; fi } trap cleanup SIGINT - if [ "$MODE" != "online" ] && [ "$MODE" != "offline" ]; then echo "An invalid value ('${MODE}') was provided for MODE env variable! Exiting..." exit 1 @@ -22,17 +29,22 @@ fi if [ "$MODE" = "online" ]; then + echo "Starting flare node in ONLINE mode" ./entrypoint_flare.sh | sed -e 's/^/[go-flare]: /;' & PID_ENTRYPOINT_FLARE=$! fi +echo "Starting rosetta server" ./entrypoint_rosetta.sh | sed -e 's/^/[rosetta]: /;' & PID_ENTRYPOINT_ROSETTA=$! # Wait for any process to exit +echo "Waiting for either process to exit" wait -n EXIT_CODE=$? +echo "Cleaning up and terminating processes due to exit code $EXIT_CODE" + # Attempt to gracefully stop the other process cleanup diff --git a/server/docker/entrypoint_rosetta.sh b/server/docker/entrypoint_rosetta.sh index 492724b..53981be 100644 --- a/server/docker/entrypoint_rosetta.sh +++ b/server/docker/entrypoint_rosetta.sh @@ -17,7 +17,8 @@ fi if [ "$MODE" = "online" ]; then # Wait for go-flare port to bind - curl ${ROSETTA_FLARE_ENDPOINT} --retry 6 --retry-connrefused --connect-timeout 5 --retry-delay 10 --silent --output /dev/null + sleep 30 + curl ${ROSETTA_FLARE_ENDPOINT} --retry 6 --retry-connrefused --retry-all-errors --connect-timeout 5 --retry-delay 10 --silent --output /dev/null if [ "$START_ROSETTA_SERVER_AFTER_BOOTSTRAP" == "true" ]; then while true; do