Axil_website/Dockerfile
Vadym Samoilenko 0f8de6479d fix: drop --no-require-module from migrator (added in Node 22.12.0)
Exit code 9 from Node.js means "Invalid argument", not SIGKILL/OOM.
--no-require-module was added in Node 22.12.0 — the cached node:22-slim
image on the VPS predates that release so Node rejects the flag immediately.

The minimal migrate.ts doesn't load lexical/form-builder, so there are no
TLA/ESM issues that required the flag in the first place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-23 21:55:04 +00:00

57 lines
1.6 KiB
Docker

FROM node:22-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
# --- Dependencies ---
FROM base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
RUN pnpm install --frozen-lockfile
# --- Development ---
FROM base AS dev
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=development
ENV WATCHPACK_POLLING=true
EXPOSE 3000
CMD ["pnpm", "dev"]
# --- Migrator (deps + src only — runs migrations before app starts) ---
FROM base AS migrator
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# --experimental-strip-types: run migrate.ts + migration files as TypeScript natively.
# --no-require-module is intentionally omitted: it was added in Node 22.12.0 and the
# cached base image may be older; our minimal migrate script doesn't load lexical so
# there are no TLA/ESM issues that required that flag.
ENV NODE_OPTIONS="--experimental-strip-types"
CMD ["node", "src/scripts/migrate.ts"]
# --- Build ---
FROM base AS build
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN pnpm build
# --- Production ---
FROM node:22-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
COPY --from=build /app/public ./public
COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=build --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]