From 96fa650caf0e5533d58cc82cbd387f9610522357 Mon Sep 17 00:00:00 2001 From: yiekheng Date: Sat, 2 May 2026 20:31:53 +0800 Subject: [PATCH] feat(docker): add multi-stage Dockerfile for cm-web-next --- docker/web-next/Dockerfile | 31 +++++++++++++++++++++++++++++++ web/public/.gitkeep | 0 2 files changed, 31 insertions(+) create mode 100644 docker/web-next/Dockerfile create mode 100644 web/public/.gitkeep diff --git a/docker/web-next/Dockerfile b/docker/web-next/Dockerfile new file mode 100644 index 0000000..c51a417 --- /dev/null +++ b/docker/web-next/Dockerfile @@ -0,0 +1,31 @@ +# syntax=docker/dockerfile:1.7 + +# --- deps --- +FROM node:22-alpine AS deps +WORKDIR /app +COPY web/package.json web/package-lock.json* ./ +# `npm install` (not `npm ci`) because the host doesn't generate the +# lockfile during dev. Docker resolves it on first build; subsequent +# builds reuse the cached layer until package.json changes. +RUN npm install --no-audit --no-fund + +# --- build --- +FROM node:22-alpine AS build +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +COPY --from=deps /app/node_modules ./node_modules +COPY web/ ./ +RUN npm run build + +# --- runtime --- +FROM node:22-alpine AS runtime +WORKDIR /app +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=3000 +ENV HOSTNAME=0.0.0.0 +COPY --from=build /app/.next/standalone ./ +COPY --from=build /app/.next/static ./.next/static +COPY --from=build /app/public ./public +EXPOSE 3000 +CMD ["node", "server.js"] diff --git a/web/public/.gitkeep b/web/public/.gitkeep new file mode 100644 index 0000000..e69de29