Files
ocs-portal-web/Dockerfile
2025-04-15 13:56:54 +07:00

35 lines
900 B
Docker

# Step 1: Build the application in a Node environment
FROM node:18 AS builder
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json to install dependencies
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy the rest of the app's source code
COPY . .
# Build the Next.js application for production
RUN npm run build
# Step 2: Create a minimal production environment
FROM node:18-alpine
# Set the working directory in the production container
WORKDIR /app
# Copy only the necessary files from the builder stage
COPY --from=builder /app/package.json /app/package-lock.json ./
COPY --from=builder /app/.next /app/.next
COPY --from=builder /app/public /app/public
COPY --from=builder /app/node_modules /app/node_modules
# Expose the port the app will run on
EXPOSE 3000
# Start the app in production mode
CMD ["npm", "run", "start"]