Skip to content

Commit

Permalink
overhaul config (.env / env vars) mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
antondlr authored Jun 25, 2024
1 parent ff989a4 commit 755ad9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -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'
SESSION_PASSWORD="your-password"
SESSION_PASSWORD=default-siren-password
SSL_ENABLED=true
# don't change these when building the docker image, only change when running outside of docker
PORT=3000
BACKEND_URL=http://127.0.0.1:3001
27 changes: 11 additions & 16 deletions docker-assets/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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_URL:-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
Expand All @@ -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
Expand Down

0 comments on commit 755ad9b

Please sign in to comment.