From a96253e7834307d17dea8e38edd3c8d67d1dff94 Mon Sep 17 00:00:00 2001 From: antondlr Date: Mon, 24 Jun 2024 13:54:00 +0200 Subject: [PATCH] move from .env file to env vars --- .env.example | 7 ++++--- Dockerfile | 1 - docker-assets/docker-entrypoint.sh | 27 +++++++++++---------------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/.env.example b/.env.example index 006c61c6..705d5415 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,8 @@ -PORT=3000 -BACKEND_URL=http://127.0.0.1:3001 BEACON_URL=http://your-BN-ip:5052 VALIDATOR_URL=http://your-VC-ip:5062 -API_TOKEN=get-it-from-'.lighthouse/validators/api-token.txt' +API_TOKEN="get-it-from-'.lighthouse/validators/api-token.txt'" SESSION_PASSWORD="your-password" SSL_ENABLED=true +# don't change these when building the docker image +PORT=3000 +BACKEND_URL=http://127.0.0.1:3001 diff --git a/Dockerfile b/Dockerfile index 5e57a2ab..3066647b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,6 @@ RUN yarn --network-timeout 300000; \ FROM alpine AS intermediate -COPY ./.env.example /app/ COPY ./docker-assets /app/docker-assets/ COPY --from=builder /app/backend/package.json /app/backend/package.json diff --git a/docker-assets/docker-entrypoint.sh b/docker-assets/docker-entrypoint.sh index 9a10d8f1..c48157ac 100755 --- a/docker-assets/docker-entrypoint.sh +++ b/docker-assets/docker-entrypoint.sh @@ -1,23 +1,18 @@ #!/bin/ash -# if no .env found, dump the default to stdout and exit -if [ ! -f /app/.env ] -then - printf "No \`/.env\` file found at the expected location (\`/app/.env\`). \n\ -Please adapt this default file to your needs and mount it within the container: \n\ -----------------\n" - cat /app/.env.example - printf "----------------\n" - exit 1 -fi - -# load .env -set -a; \ -. /app/.env; \ +# configure default vars if none provided +set -a +PORT=${PORT:-3000} +BACKEND_URL=${BACKEND_URLs:-=http://127.0.0.1:3001} +BEACON_URL=${BEACON_URL:-http://your-BN-ip:5052} +VALIDATOR_URL=${VALIDATOR_URL:-http://your-VC-ip:5062} +API_TOKEN=${API_TOKEN:-"get-it-from-'.lighthouse/validators/api-token.txt'"} +SESSION_PASSWORD=${SESSION_PASSWORD:-default-siren-password} +SSL_ENABLED=${SSL_ENABLED:-true} set +a # if bn/vc api unreachable, print message and exit -tests="${BEACON_URL:-http://your-BN-ip:5052} ${VALIDATOR_URL:-http://your-VC-ip:5062}" +tests="${BEACON_URL} ${VALIDATOR_URL}" for test in $tests; do nc -z "${test#*//}" if [ $? -eq 1 ]; then @@ -26,7 +21,7 @@ for test in $tests; do fi done # check api token -api_response_code=$(curl -sIX GET "${VALIDATOR_URL:-http://127.0.0.1}/lighthouse/version" -H "Authorization: Bearer ${API_TOKEN:-default_siren_token}" | head -n 1 | awk '{print $2}') +api_response_code=$(curl -sIX GET "${VALIDATOR_URL}/lighthouse/version" -H "Authorization: Bearer ${API_TOKEN}" | head -n 1 | awk '{print $2}') if [ "$api_response_code" != '200' ]; then printf "validator api issue, server response: %s \n" "${api_response_code:-no_response}" fail=true