feat: Implement multi-stage Dockerfile for robust Nuxt build
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -1,4 +1,5 @@
|
||||
FROM node:24-alpine
|
||||
# Stage 1: Builder
|
||||
FROM node:24-alpine AS builder
|
||||
|
||||
# Install dumb-init, Python, and build tools for native builds
|
||||
RUN apk add --no-cache dumb-init python3 build-base
|
||||
@@ -9,8 +10,8 @@ WORKDIR /app
|
||||
# Copy package files
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --production
|
||||
# Install all dependencies (including dev dependencies for building)
|
||||
RUN npm install
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
@@ -18,6 +19,21 @@ COPY . .
|
||||
# Build the application
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Runner
|
||||
FROM node:24-alpine
|
||||
|
||||
# Install dumb-init for signal handling
|
||||
RUN apk add --no-cache dumb-init
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only production dependencies from builder stage
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Copy the built application from builder stage
|
||||
COPY --from=builder /app/.output ./.output
|
||||
|
||||
# Create data directory and database file for SQLite
|
||||
RUN mkdir -p /app/data && touch /app/data/sermons.db
|
||||
|
||||
|
||||
Reference in New Issue
Block a user