Skip to content

Commit

Permalink
wait for db before starting the server (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek authored Mar 5, 2024
1 parent 2703da6 commit 4cd2433
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
!package.json
!tsconfig.build.json
!tsconfig.json
!entrypoint.sh
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ 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 ./
COPY package.json package-lock.json entrypoint.sh ./
RUN npm ci

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

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

FROM base as development

Expand Down
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

echo "Looking for the database ..."
while ! pg_isready -q -d $STORAGE_URI
do
echo "Waiting for database."
sleep 2
done
echo "Found database."
echo "Starting the application..."

npm run start:prod

0 comments on commit 4cd2433

Please sign in to comment.