From a803b26472426595e8a110c088776a56f1894b88 Mon Sep 17 00:00:00 2001 From: Aleksandr Soloshenko Date: Sat, 26 Jul 2025 07:32:38 +0700 Subject: [PATCH] [deploy] new entrypoint design --- build/package/Dockerfile | 6 +++++- scripts/docker-entrypoint.sh | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 1d342da..2cc5d4d 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -44,6 +44,10 @@ COPY --from=build /go/src/app /app EXPOSE 3000 USER guest -HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 CMD curl -fs http://localhost:3000/health ENTRYPOINT ["/docker-entrypoint.sh"] + +HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ + CMD curl -fs http://localhost:3000/health + +CMD [ "/app/app" ] diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 2cee6eb..f06de95 100755 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -4,7 +4,10 @@ # Immediately exit if any command has a non-zero exit status. set -e -# Execute any pre-startup scripts or tasks. -/app/app db:migrate up +# Execute DB migrations only when the main application is about to run +if [ "${1:-}" = "/app/app" ]; then + /app/app db:migrate up +fi -exec /app/app "$@" +# Execute the main application +exec "$@" \ No newline at end of file