All checks were successful
Build & Push Docker Image / build-and-push (push) Successful in 46s
npm ci fails with optional platform-specific dependencies (@emnapi/core, @emnapi/runtime) that are not recorded in the lock file for Alpine Linux. npm install handles optional dependencies correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
42 lines
1.2 KiB
Docker
42 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
# ── Stage 1: build ──────────────────────────────────────────────────────────
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies first (better layer caching)
|
|
COPY package.json package-lock.json ./
|
|
RUN npm install
|
|
|
|
# Copy source and build
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Prune dev dependencies
|
|
RUN npm prune --production
|
|
|
|
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
|
|
FROM node:22-alpine AS runtime
|
|
|
|
WORKDIR /app
|
|
|
|
# Non-root user for security
|
|
RUN addgroup -g 1001 tonemark && \
|
|
adduser -D -u 1001 -G tonemark tonemark
|
|
|
|
# Copy built output and production node_modules
|
|
COPY --from=builder --chown=tonemark:tonemark /app/build ./build
|
|
COPY --from=builder --chown=tonemark:tonemark /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=tonemark:tonemark /app/package.json ./
|
|
|
|
USER tonemark
|
|
|
|
EXPOSE 3000
|
|
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
HOST=0.0.0.0
|
|
|
|
CMD ["node", "build/index.js"]
|