Some checks failed
Build & Deploy to Staging / Build & Deploy to Staging (push) Has been cancelled
- swagger.ts: changed apis glob from dist/routes/*.js to src/routes/*.ts so OpenAPI spec includes demo endpoints during tests (fixes 6 test failures) - Dockerfile: copy src/ to final stage for runtime swagger-jsdoc - Updated stale /v1/signup/verify test refs to /v1/signup/free (endpoint was removed when free tier was discontinued)
73 lines
1.9 KiB
Docker
73 lines
1.9 KiB
Docker
# ============================================
|
|
# Stage 1: Builder
|
|
# ============================================
|
|
FROM node:22-bookworm-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files for dependency installation
|
|
COPY package*.json tsconfig.json ./
|
|
|
|
# Install ALL dependencies (including devDependencies for build)
|
|
RUN npm install
|
|
|
|
# Copy source code and build scripts
|
|
COPY src/ src/
|
|
COPY scripts/ scripts/
|
|
COPY public/ public/
|
|
|
|
# Compile TypeScript
|
|
RUN npx tsc
|
|
|
|
# Generate OpenAPI spec
|
|
RUN node scripts/generate-openapi.mjs
|
|
|
|
# Build HTML templates
|
|
RUN node scripts/build-html.cjs
|
|
|
|
# Create swagger-ui symlink in builder stage
|
|
RUN rm -f public/swagger-ui && ln -s /app/node_modules/swagger-ui-dist public/swagger-ui
|
|
|
|
# ============================================
|
|
# Stage 2: Production
|
|
# ============================================
|
|
FROM node:22-bookworm-slim AS production
|
|
|
|
# Install Chromium and dependencies as root
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
chromium fonts-liberation \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user
|
|
RUN groupadd --gid 1001 docfast \
|
|
&& useradd --uid 1001 --gid docfast --shell /bin/bash --create-home docfast
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files for production dependency installation
|
|
COPY package*.json ./
|
|
|
|
# Install ONLY production dependencies
|
|
RUN npm install --omit=dev
|
|
|
|
# Copy compiled artifacts from builder stage
|
|
COPY --from=builder /app/dist ./dist
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/src ./src
|
|
|
|
# Recreate swagger-ui symlink in production stage
|
|
RUN rm -f public/swagger-ui && ln -s /app/node_modules/swagger-ui-dist public/swagger-ui
|
|
|
|
# Set Puppeteer environment variables
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
|
|
|
# Create data directory and set ownership to docfast user
|
|
RUN mkdir -p /app/data && chown -R docfast:docfast /app
|
|
|
|
# Switch to non-root user
|
|
USER docfast
|
|
|
|
ENV PORT=3100
|
|
EXPOSE 3100
|
|
CMD ["node", "dist/index.js"]
|