Skip to content

Commit 4cd2433

Browse files
authored
wait for db before starting the server (#14)
1 parent 2703da6 commit 4cd2433

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
!package.json
66
!tsconfig.build.json
77
!tsconfig.json
8+
!entrypoint.sh

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ RUN npm run build
1212

1313
FROM base as production
1414

15+
RUN apt-get update
16+
RUN apt-get install -y postgresql-client
17+
1518
ENV NODE_ENV=production
1619

1720
USER node
1821
WORKDIR /home/node/app
1922

20-
COPY package.json package-lock.json ./
23+
COPY package.json package-lock.json entrypoint.sh ./
2124
RUN npm ci
2225

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

25-
ENTRYPOINT ["npm", "run", "start:prod"]
28+
CMD ["./entrypoint.sh"]
2629

2730
FROM base as development
2831

entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
echo "Looking for the database ..."
4+
while ! pg_isready -q -d $STORAGE_URI
5+
do
6+
echo "Waiting for database."
7+
sleep 2
8+
done
9+
echo "Found database."
10+
echo "Starting the application..."
11+
12+
npm run start:prod

0 commit comments

Comments
 (0)