FROM node:12.18.2-alpine3.12# Install PM2 globallyRUN npm install--global pm2
#Install Gatsby CLIRUN npm install-g gatsby-cli
RUN mkdir /app
WORKDIR /appRUN chmod-R 777 /app
# Add node_modules to the pathENV PATH /app/node_modules/.bin:$PATH# Installing dependenciesCOPY package*.json /app/RUN cd /app/
RUN npm installCOPY . /app/# Building appRUN npm run build
# Run container as non-root (unprivileged) user# The node user is provided in the Node.js Alpine base imageUSER nodeEXPOSE 8000# Run npm start script with PM2 when container startsCMD [ "pm2-runtime", "npm", "--", "serve" ]
Hi, Here the configuration that worked for me.
Then "serve" in package.json goes like this .
Hey Ernesto et all thanks for sharing,
When trying to run this i get stuck with the following error
"Recreating frontend_web_1 ... done
Attaching to frontend_web_1
web_1 | 2020-11-14T02:58:15: PM2 log: Launching in no daemon mode
web_1 | 2020-11-14T02:58:15: PM2 log: App [npm:0] starting in -fork mode-
web_1 | 2020-11-14T02:58:15: PM2 log: App [npm:0] online
web_1 | Usage: npm
web_1 | where is one of:"
that repeats itself until i get
"web_1 | 2020-11-14T02:58:24: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
web_1 | 2020-11-14T02:58:24: PM2 log: Script /usr/local/bin/npm had too many unstable restarts (16). Stopped. "errored"
web_1 | 2020-11-14T02:58:25: PM2 log: 0 application online, retry = 3
web_1 | 2020-11-14T02:58:27: PM2 log: 0 application online, retry = 2
web_1 | 2020-11-14T02:58:29: PM2 log: 0 application online, retry = 1
web_1 | 2020-11-14T02:58:31: PM2 log: 0 application online, retry = 0
web_1 | 2020-11-14T02:58:31: PM2 log: Stopping app:npm id:0
web_1 | 2020-11-14T02:58:31: PM2 error: app=npm id=0 does not have a pid
web_1 | 2020-11-14T02:58:31: PM2 log: PM2 successfully stopped"
Any ideas?
Many thanks