52 lines
1006 B
Docker
52 lines
1006 B
Docker
# Dockerfile for Nuxt.js Application
|
|
# Multi-stage build for optimized image size
|
|
|
|
# Stage 1: Build Stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy application files
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Production Stage
|
|
FROM node:20-alpine AS runner
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install production dependencies only (skip postinstall script)
|
|
RUN npm ci --omit=dev --ignore-scripts
|
|
|
|
# Copy built application from builder stage
|
|
COPY --from=builder /app/.output /app/.output
|
|
COPY --from=builder /app/.nuxt /app/.nuxt
|
|
COPY --from=builder /app/nuxt.config.ts /app/nuxt.config.ts
|
|
COPY --from=builder /app/node_modules /app/node_modules
|
|
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Set environment variables
|
|
ENV NODE_ENV=production
|
|
ENV HOST=0.0.0.0
|
|
ENV PORT=3000
|
|
|
|
|
|
# Start the application
|
|
CMD ["node", ".output/server/index.mjs"]
|