I'm try to reload my node js app code inside docker container. I use pm2 as process manager. Here is my configurations: Dockerfile
FROM node:6.9.5
LABEL maintainer "denis.ostapenko2@gmail.com"
RUN mkdir -p /usr/src/koa2-app
COPY . /usr/src/koa2-app
WORKDIR /usr/src/koa2-app
RUN npm i -g pm2
RUN npm install
EXPOSE 9000
CMD [ "npm", "run", "production"]
ecosystem.prod.config.json (aka pm2 config)
{
"apps" : [
{
"name" : "koa2-fp",
"script" : "./bin/www.js",
"watch" : true,
"merge_logs" : true,
"log_date_format": "YYYY-MM-DD HH:mm Z",
"env": {
"NODE_ENV": "production",
"PROTOCOL": "http",
"APP_PORT": 3000
},
"instances": 4,
"exec_mode" : "cluster_mode",
"autorestart": true
}
]
}
docker-compose.yaml
version: "3"
services:
web:
build: .
volumes:
- ./:/koa2-app
ports:
- "3000:3000"
npm run production - pm2 start --attach ecosystem.prod.config.json
I run 'docker-compose up' in the CLI and it works, I'm able to interact with my app on localhost:3000. But if make some change to code it will not show up in web. How can I configure code reloading inside docker?
P.S. And best practices question: Is it really OK to develop using docker stuff? Or docker containers is most preferable for production use.
via TK-95
No comments:
Post a Comment