diff --git a/.dockerignore b/.dockerignore index fc3af8b..3f3cbbf 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,9 @@ -# dependencies & build output (rebuilt inside the image) -node_modules -.next -out -build -dist +# Only ignore repo-root build artifacts — NOT prebuilt/standalone/{.next,node_modules} +/node_modules +/.next +/out +/build +/dist # version control & CI .git @@ -18,7 +18,7 @@ dist .claude skills -# project meta / docs (keep messages/ — required by next-intl at build time) +# project meta / docs memory-bank docs *.md @@ -31,10 +31,9 @@ run-mvp.bat scripts db -# docker +# docker sources not needed for prebuilt pack (full Dockerfile still local-only) Dockerfile docker-compose.yml -.dockerignore # logs & debug npm-debug.log* @@ -48,7 +47,7 @@ logs *.tsbuildinfo next-env.d.ts -# env & local data (must not leak into image) +# env & local data .env .env.local .env*.local diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f12705c..205f2f3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -74,8 +74,14 @@ jobs: - name: Build image from prebuilt run: | + set -euo pipefail test -f prebuilt/standalone/server.js - docker build -f Dockerfile.prebuilt -t "$IMAGE_NAME" . + test -f prebuilt/standalone/.next/BUILD_ID + test -d prebuilt/standalone/node_modules + test -d prebuilt/static + # Context = prebuilt/ so root .dockerignore cannot strip standalone/.next + docker build -f Dockerfile.prebuilt -t "$IMAGE_NAME" prebuilt + - name: Restart container env: diff --git a/Dockerfile.prebuilt b/Dockerfile.prebuilt index f580dd5..32dacf8 100644 --- a/Dockerfile.prebuilt +++ b/Dockerfile.prebuilt @@ -1,8 +1,8 @@ # Packs a pre-built Next.js standalone output — no npm / next build on the server. -# Expects build context: -# prebuilt/standalone/ ← contents of .next/standalone -# prebuilt/static/ ← contents of .next/static -# prebuilt/public/ ← public/ +# Build context must be the `prebuilt/` directory: +# standalone/ ← contents of .next/standalone (includes .next/BUILD_ID + node_modules) +# static/ ← contents of .next/static +# public/ ← public/ FROM node:22-alpine AS runner WORKDIR /app @@ -14,9 +14,9 @@ ENV HOSTNAME=0.0.0.0 RUN addgroup --system --gid 1001 nodejs \ && adduser --system --uid 1001 nextjs -COPY --chown=nextjs:nodejs prebuilt/standalone/ ./ -COPY --chown=nextjs:nodejs prebuilt/public ./public -COPY --chown=nextjs:nodejs prebuilt/static ./.next/static +COPY --chown=nextjs:nodejs standalone/ ./ +COPY --chown=nextjs:nodejs public ./public +COPY --chown=nextjs:nodejs static ./.next/static USER nextjs