35 lines
645 B
Docker
35 lines
645 B
Docker
# Stage 1: Builder
|
|
FROM node:18-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production
|
|
FROM node:18-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies only for production
|
|
COPY package*.json ./
|
|
RUN npm ci --only=production && npm cache clean --force
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder /app/.output ./.output
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
|
|
# Expose the port
|
|
EXPOSE 3000
|
|
|
|
# Start the application
|
|
CMD ["node", ".output/server/index.mjs"] |