I'm trying to launch 2 nodejs app inside a Docker container using PM2, so I made a custom Dockerfile with all the projects config
FROM node:argon
RUN npm install pm2 -g --silent
VOLUME ./src/app:/usr/src/app
WORKDIR /usr/src/app
RUN git clone https://github.com/yoonic/atlas.git backend
RUN cd backend && \
npm i --silent && \
pm2 start npm --name "backend" -- run dev --no-daemon
RUN git clone https://github.com/yoonic/nicistore.git frontend
RUN cd frontend && \
npm i --silent && \
sed -i "s#api.atlas.baseUrl#http://localhost:8000/v1#" config/client/development.js && \
pm2 start npm --name "frontend" -- run dev --no-daemon
I start this container with docker-compose up
with this config
# NodeJS
nodejs:
build: docker/nodejs
container_name: nodejs
ports:
- 53000:3000
- 54000:4000
When all the container is set up, I get the PM2 process list in my terminal then docker-compose start all my containers but I the nodejs one fail instantly
nodejs exited with code 0
My nodejs app are working inside my container but this one exit instantly...
This the right way to make this work ? PM2 is maybe not needed ?
How can I make this working ?
EDIT
The container exit when I'm not using --no-daemon
because it think everything is done.
But when I'm using --no-daemon
the build process is never finished because it show me nodejs app logs