diff --git a/.dockerignore b/.dockerignore index 42beeac..5f85769 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,3 +5,4 @@ !package.json !tsconfig.build.json !tsconfig.json +!entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 0a3511c..23180cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..70e4c43 --- /dev/null +++ b/entrypoint.sh @@ -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 \ No newline at end of file