egentrening/Dockerfile
2025-09-03 16:05:08 +02:00

37 lines
912 B
Docker

# Build stage - includes dev dependencies for building the app
FROM node:22-alpine AS build
# Set working directory for build operations
WORKDIR /app
# Copy package files to install dependencies
COPY package*.json ./
# Install all dependencies including dev dependencies needed for build
RUN npm ci
# Copy source code and build the application
COPY . .
RUN npm run build
# Production stage - clean runtime environment
FROM node:22-alpine AS production
# Set working directory for runtime
WORKDIR /app
# Copy package files for production install
COPY package*.json ./
# Install only production dependencies (excludes dev dependencies)
RUN npm ci --only=production
# Copy built application from build stage
COPY --from=build /app/build ./build
# Expose the port the application will run on
EXPOSE 3000
# Set environment to production
ENV NODE_ENV=production
# Start the application
CMD ["node", "build"]