Add Dockerfiles for json-server and application runtime environments

This commit is contained in:
Mathieu 2025-11-20 12:08:24 +01:00
parent a06288c70a
commit 3ece8580ba
2 changed files with 42 additions and 0 deletions

23
Dockerfile Normal file
View file

@ -0,0 +1,23 @@
# Use an official Node runtime as a parent image
FROM node:22.17
RUN corepack enable
# Set the working directory in the container
WORKDIR /usr/src/app
# Copy the current directory contents into the container at /usr/src/app
COPY . .
# Install your app dependencies using the npm binary
RUN yarn
RUN yarn build
# Install PM2 globally
RUN npm install pm2 -g
# Your app binds to port 3000 so you'll use the EXPOSE instruction to have it mapped by the docker daemon
EXPOSE 3000
# Define the runtime command to run your application
CMD ["pm2-runtime", "start", "npm", "--", "start"]

19
Dockerfile.jsonserver Normal file
View file

@ -0,0 +1,19 @@
FROM node:20-alpine
WORKDIR /app
# Install json-server globally
RUN npm install -g json-server@0.17.4
# Create data directory
RUN mkdir -p /data
# Copy initial db.json
COPY db.json /data/db.json
EXPOSE 3001
# Use volume mount for persistence
VOLUME ["/data"]
CMD ["json-server", "--watch", "/data/db.json", "--host", "0.0.0.0", "--port", "3001"]