Skip to content

Commit

Permalink
fix: properly handle system signals in pwa docker container (#1471)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored Aug 15, 2023
1 parent d0984ce commit 2b9d8ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ RUN node scripts/compile-docker-scripts
COPY dist/* /workspace/dist/

FROM node:18.16.0-alpine
RUN apk add --no-cache tini
COPY --from=buildstep /workspace/dist /dist
RUN cd dist && npm install
ARG displayVersion=
Expand All @@ -37,4 +38,4 @@ EXPOSE 4200 9113
RUN mkdir /.pm2 && chmod 777 -Rf /.pm2 && touch /dist/ecosystem.yml && chmod 777 -f /dist/ecosystem.yml
USER nobody
HEALTHCHECK --interval=60s --timeout=20s --start-period=2s CMD node /dist/healthcheck.js
ENTRYPOINT ["sh","/dist/entrypoint.sh"]
ENTRYPOINT [ "/sbin/tini", "--", "sh", "/dist/entrypoint.sh" ]
8 changes: 2 additions & 6 deletions dist/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

set -e

trap 'echo recieved INT; exit 1' SIGINT
trap 'echo recieved TERM; exit 0' SIGTERM
trap 'echo recieved KILL; exit 1' SIGKILL

if [ -z "$*" ]
then
# use 'node dist/<theme>/run-standalone'
# use 'exec node dist/<theme>/run-standalone'
# instead of pm2 to fallback to running
# a single theme only

node dist/build-ecosystem.js
pm2-runtime dist/ecosystem.yml
exec pm2-runtime dist/ecosystem.yml
else
exec "$@"
fi
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
serviceWorker: 'false'
# activeThemes: b2b
# activeThemes: b2c
# command: ['node', 'dist/b2c/run-standalone']
# command: ['node', 'dist/b2b/run-standalone']
environment:
# ICM_BASE_URL:
LOGGING: 'true'
Expand Down

0 comments on commit 2b9d8ea

Please sign in to comment.