You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
909 B
Docker

# Use the official Node.js image as the base image
FROM node:22.16.0 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json (if available) to the working directory
COPY package*.json ./
# Install the application dependencies
RUN npm install
# Copy the rest of the application code to the working directory
COPY . .
# Production stage
FROM node:22.16.0-alpine AS production
# Set the working directory inside the container
WORKDIR /app
# Copy dependencies from builder stage
COPY --from=builder /app/node_modules ./node_modules
# Copy application code from builder stage
COPY --from=builder /app/. .
# Install pm2 globally
RUN npm install -g pm2
# Expose the port that the application listens on
EXPOSE 3000
# Define the command to run the application in production mode with pm2.json config
CMD ["pm2", "start", "pm2.json", "--no-daemon"]