How to start strapi-docker with pm2?

Viewed 588

Is there any way to start strapi/strapi docker images with pm2? Since the default command for strapi/strapi docker images is strapi develop.

2 Answers

PM2 is already included in the Docker image

Use docker-compose to start your project then you will be able to get inside your guest os image and run commands.

sudo docker exec -it strapi bash create ecosystem.config.js file

pm2 start ecosystem.config.js --env production

Please check this blog post.

Looks like the only way to do this is install strapi using cli, then ship it to docker using strapi/base docker image and add pm2 in the Dockerfile.

FROM strapi/base

WORKDIR /srv/app

COPY ./package.json ./
COPY ./yarn.lock ./

RUN npm install pm2 -g

RUN yarn install

COPY . .

ENV NODE_ENV production

RUN yarn build

EXPOSE 1337

CMD ["pm2-runtime", "server.js"]
Related