Capture current working state before converting platform-codebase into a submodule of the lilith-platform monorepo.
71 lines
2 KiB
Docker
71 lines
2 KiB
Docker
# =============================================================================
|
|
# Queue Worker Service Dockerfile
|
|
# =============================================================================
|
|
# Multi-stage build for production-ready queue worker
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Stage 1: Dependencies
|
|
# -----------------------------------------------------------------------------
|
|
FROM node:22-alpine AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
# Copy package files
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
# Install dependencies
|
|
RUN pnpm install --frozen-lockfile --ignore-scripts
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Stage 2: Builder
|
|
# -----------------------------------------------------------------------------
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install pnpm
|
|
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
|
|
# Copy dependencies from deps stage
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN pnpm run build
|
|
|
|
# -----------------------------------------------------------------------------
|
|
# Stage 3: Production
|
|
# -----------------------------------------------------------------------------
|
|
FROM node:22-alpine AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apk add --no-cache curl
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nestjs -u 1001 -G nodejs
|
|
|
|
# Copy built application
|
|
COPY --from=builder --chown=nestjs:nodejs /app/dist ./dist
|
|
COPY --from=deps --chown=nestjs:nodejs /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=nestjs:nodejs /app/package.json ./package.json
|
|
|
|
# Switch to non-root user
|
|
USER nestjs
|
|
|
|
# Expose ports
|
|
EXPOSE 3080 3081
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD curl -f http://localhost:3080/health || exit 1
|
|
|
|
# Start the application
|
|
CMD ["node", "dist/main.js"]
|