Refactor Dockerfile.prebuilt and GitHub Actions workflow for streamlined Next.js deployment. Consolidated file copying in Dockerfile to simplify the build context. Updated workflow to assemble a complete standalone tree and verify artifact integrity before building the Docker image.

This commit is contained in:
smhk1376 committed 2026-09-24 15:35:51 +03:30
1 parent 13d122e905
commit 95841ab09a
2 files changed
+45 -27

No files matched your search

+6 -11
View File
@@ -1,10 +1,8 @@
# Packs a pre-built Next.js standalone output — no npm / next build on the server.
# 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/
# Runtime image for a fully assembled Next.js standalone tree.
# Build context = prebuilt/ and must already contain:
# server.js, .next/BUILD_ID, .next/static/, public/, node_modules/, …
FROM node:22-alpine AS runner
FROM node:22-alpine
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
@@ -14,12 +12,9 @@ ENV HOSTNAME=0.0.0.0
RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 nextjs
COPY --chown=nextjs:nodejs standalone/ ./
COPY --chown=nextjs:nodejs public ./public
COPY --chown=nextjs:nodejs static ./.next/static
# Single COPY of an already-complete app root (avoids missing hidden .next)
COPY --chown=nextjs:nodejs . ./
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]