Files
nlcc-itinerary/Dockerfile

54 lines
1.2 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, wget for healthcheck, and build tools for native modules
RUN apk add --no-cache dumb-init wget python3 build-base
# Set working directory
WORKDIR /app
# Copy package files for rebuilding native modules
COPY --from=builder /app/package*.json ./
# Copy node_modules from builder
COPY --from=builder /app/node_modules ./node_modules
# Rebuild native modules for production environment
RUN npm rebuild better-sqlite3
# Copy the built application from builder stage
COPY --from=builder /app/.output ./.output
# Create data directory (don't pre-create database file)
RUN mkdir -p /app/data
# 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"]