48 lines
1.0 KiB
Docker
48 lines
1.0 KiB
Docker
# 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
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install all dependencies (including dev dependencies for building)
|
|
RUN npm install
|
|
|
|
# Copy application code
|
|
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
|
|
|
|
# Expose port
|
|
EXPOSE 3000
|
|
|
|
# Use dumb-init to handle signals properly
|
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
|
|
|
# Start the application
|
|
CMD ["node", ".output/server/index.mjs"]
|