Skip to content

Commit

Permalink
fix(dockerfile, docker-compose.yaml): add wait for db and redis to se…
Browse files Browse the repository at this point in the history
…rver container

When starting the server via docker-compose currently the server starts up faster than the postgres
instance. This causes the server app to crash. The fix now adds a wait script that pings the
database and the cache containers unit they properly start up. This delays the server boot until all
deps are started.
  • Loading branch information
gjedlicska committed Jan 30, 2021
1 parent cd4e065 commit 356467b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ RUN npm run build
FROM node as runtime

RUN apk add --no-cache tini=0.19.0-r0
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait

# Use a non-root user for increased security.
USER node
Expand All @@ -54,4 +56,4 @@ COPY --chown=node packages/server /home/node/server
# Init for containers https://github.com/krallin/tini
ENTRYPOINT [ "/sbin/tini", "--" ]

CMD ["node", "bin/www"]
CMD /wait && node bin/www
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
- "3000:3000"
environment:
DEBUG: "speckle:*"
WAIT_HOSTS: database:5432, redis:6379
env_file:
- .env

Expand Down

0 comments on commit 356467b

Please sign in to comment.