Add pm2 in dockerfile & restart docker ps on error (#97)

This commit is contained in:
Ali Sharafi
2024-04-22 16:14:27 +02:00
committed by GitHub
parent 4ed92b246f
commit f215ab53db
2 changed files with 13 additions and 11 deletions

View File

@@ -1,19 +1,20 @@
# syntax=docker/dockerfile:1.3
FROM node:18-alpine AS builder
COPY --chown=1000:1000 . /fredy
FROM node:18
WORKDIR /fredy
USER 1000
COPY . /fredy
RUN yarn install
RUN yarn global add pm2
RUN yarn run prod
FROM node:16-alpine
COPY --from=builder --chown=1000:1000 /fredy /fredy
RUN mkdir /db /conf && \
chown 1000:1000 /db /conf && \
chmod 777 -R /db/ && \
ln -s /db /fredy/db && ln -s /conf /fredy/conf
EXPOSE 9998
USER 1000
VOLUME [ "/conf", "/db" ]
WORKDIR /fredy
CMD node index.js --no-daemon
CMD pm2-runtime index.js

View File

@@ -1,4 +1,4 @@
version: '3.3'
version: '3.8'
services:
fredy:
container_name: fredy
@@ -13,3 +13,4 @@ services:
- ./db:/db
ports:
- 9998:9998
restart: unless-stopped