Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for db using healthchecks #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
!package.json
!tsconfig.build.json
!tsconfig.json
!entrypoint.sh
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ RUN npm run build

FROM base as production

RUN apt-get update
RUN apt-get install -y postgresql-client

ENV NODE_ENV=production

USER node
WORKDIR /home/node/app

COPY package.json package-lock.json entrypoint.sh ./
COPY package.json package-lock.json ./
RUN npm ci

COPY --from=production_buildstage /home/node/app/dist /home/node/app/dist

CMD ["./entrypoint.sh"]
ENTRYPOINT ["npm", "run", "start:prod"]

FROM base as development

Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ services:
build:
context: .
target: development
depends_on:
postgres:
condition: service_healthy
tty: true
stdin_open: true
ports:
Expand All @@ -24,6 +27,11 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_PORT: ${POSTGRES_PORT:-5432}
POSTGRES_USER: ${POSTGRES_USER}
healthcheck:
test: /usr/local/bin/pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}
interval: 5s
timeout: 10s
retries: 120
volumes:
- postgres_data:/var/lib/postgresql/data/pgdata
volumes:
Expand Down
12 changes: 0 additions & 12 deletions entrypoint.sh

This file was deleted.