Refactor Dockerfile and .dockerignore for clarity and build context. Updated paths in Dockerfile.prebuilt to reflect new directory structure and improved .dockerignore to better manage ignored files. Enhanced GitHub Actions workflow to ensure proper build context for Docker image creation.

This commit is contained in:
smhk1376 committed 2026-09-24 15:31:06 +03:30
1 parent 9b48611a61
commit 13d122e905
3 files changed
+23 -18

No files matched your search

+9 -10
View File
@@ -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
+7 -1
View File
@@ -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:
+7 -7
View File
@@ -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