From 3ece8580ba683a9ea6f91f212fbeb6c68b58d9d3 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Thu, 20 Nov 2025 12:08:24 +0100 Subject: [PATCH] Add Dockerfiles for json-server and application runtime environments --- Dockerfile | 23 +++++++++++++++++++++++ Dockerfile.jsonserver | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Dockerfile create mode 100644 Dockerfile.jsonserver diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8478929 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/Dockerfile.jsonserver b/Dockerfile.jsonserver new file mode 100644 index 0000000..d459dc7 --- /dev/null +++ b/Dockerfile.jsonserver @@ -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"]