Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
feat(docker): add env var to docker file to wait
Browse files Browse the repository at this point in the history
This will tell the container to not start the server until after a certain # of seconds. This is useful in ECS where litestream needs some time to load the database before the service starts sending it
  • Loading branch information
dtfiedler committed May 8, 2024
1 parent 6fbfe4f commit 21c3af0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ WORKDIR /usr/src/app
COPY --from=busybox:1.35.0-uclibc /bin/sh /bin/sh
COPY --from=busybox:1.35.0-uclibc /bin/chown /bin/chown
COPY --from=busybox:1.35.0-uclibc /bin/chmod /bin/chmod
COPY --from=busybox:1.35.0-uclibc /bin/sleep /bin/sleep

# Copy build files
COPY --from=builder /usr/src/app .
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
GATEWAY_PROTOCOL: ${GATEWAY_PROTOCOL:-http}
PREFETCH_CONTRACTS: ${PREFETCH_CONTRACTS:-false}
BLOCKLISTED_CONTRACT_IDS: ${BLOCKLISTED_CONTRACT_IDS:-fbU8Y4NMKKzP4rmAYeYj6tDrVDo9XNbdyq5IZPA31WQ}
WAIT_TIME_SECONDS: ${WAIT_TIME_SECONDS:-}
ports:
- '3000:3000'

Expand Down
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@ if [ -d "/usr/src/app/cache" ]; then
chmod -R 755 /usr/src/app/cache
fi

if [[ -n "$WAIT_TIME_SECONDS" ]]; then
# Sleep for the number of seconds specified in WAIT_TIME_SECONDS
echo "Waiting for $WAIT_TIME_SECONDS seconds before starting the service..."
sleep $WAIT_TIME_SECONDS
fi

# run the app
exec /nodejs/bin/node /usr/src/app/dist/app.js

0 comments on commit 21c3af0

Please sign in to comment.