From 86ad3b7566902eb5a93ae6617d4e253945667fb5 Mon Sep 17 00:00:00 2001 From: Beng Eu Date: Wed, 16 Mar 2022 11:50:28 +0100 Subject: [PATCH] feat: use PM2 in `Dockerfile` As a temporary mitigation for nodejs/node#39671. --- Dockerfile | 5 +++-- ecosystem.config.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 ecosystem.config.js diff --git a/Dockerfile b/Dockerfile index af39df48..519bf827 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,10 +12,11 @@ RUN npm ci RUN npm run build FROM node:14-alpine +RUN npm install -g pm2 WORKDIR /app COPY migrations migrations -COPY package.json . +COPY ecosystem.config.js package.json . COPY --from=0 /app/node_modules node_modules COPY --from=1 /app/dist dist EXPOSE 5000 -CMD ["npm", "run", "start"] +CMD ["pm2-runtime", "ecosystem.config.js"] diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 00000000..233d62b8 --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,11 @@ +module.exports = { + apps: [ + { + env: { + NODE_ENV: 'production', + }, + exp_backoff_restart_delay: 100, + script: 'dist/server.js', + }, + ], +}