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:
1 parent
9b48611a61
commit
13d122e905
3 files changed
+23
-18
No files matched your search
+9
-10
@@ -1,9 +1,9 @@
|
|||||||
# dependencies & build output (rebuilt inside the image)
|
# Only ignore repo-root build artifacts — NOT prebuilt/standalone/{.next,node_modules}
|
||||||
node_modules
|
/node_modules
|
||||||
.next
|
/.next
|
||||||
out
|
/out
|
||||||
build
|
/build
|
||||||
dist
|
/dist
|
||||||
|
|
||||||
# version control & CI
|
# version control & CI
|
||||||
.git
|
.git
|
||||||
@@ -18,7 +18,7 @@ dist
|
|||||||
.claude
|
.claude
|
||||||
skills
|
skills
|
||||||
|
|
||||||
# project meta / docs (keep messages/ — required by next-intl at build time)
|
# project meta / docs
|
||||||
memory-bank
|
memory-bank
|
||||||
docs
|
docs
|
||||||
*.md
|
*.md
|
||||||
@@ -31,10 +31,9 @@ run-mvp.bat
|
|||||||
scripts
|
scripts
|
||||||
db
|
db
|
||||||
|
|
||||||
# docker
|
# docker sources not needed for prebuilt pack (full Dockerfile still local-only)
|
||||||
Dockerfile
|
Dockerfile
|
||||||
docker-compose.yml
|
docker-compose.yml
|
||||||
.dockerignore
|
|
||||||
|
|
||||||
# logs & debug
|
# logs & debug
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
@@ -48,7 +47,7 @@ logs
|
|||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
next-env.d.ts
|
next-env.d.ts
|
||||||
|
|
||||||
# env & local data (must not leak into image)
|
# env & local data
|
||||||
.env
|
.env
|
||||||
.env.local
|
.env.local
|
||||||
.env*.local
|
.env*.local
|
||||||
|
|||||||
@@ -74,8 +74,14 @@ jobs:
|
|||||||
|
|
||||||
- name: Build image from prebuilt
|
- name: Build image from prebuilt
|
||||||
run: |
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
test -f prebuilt/standalone/server.js
|
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
|
- name: Restart container
|
||||||
env:
|
env:
|
||||||
|
|||||||
+7
-7
@@ -1,8 +1,8 @@
|
|||||||
# Packs a pre-built Next.js standalone output — no npm / next build on the server.
|
# Packs a pre-built Next.js standalone output — no npm / next build on the server.
|
||||||
# Expects build context:
|
# Build context must be the `prebuilt/` directory:
|
||||||
# prebuilt/standalone/ ← contents of .next/standalone
|
# standalone/ ← contents of .next/standalone (includes .next/BUILD_ID + node_modules)
|
||||||
# prebuilt/static/ ← contents of .next/static
|
# static/ ← contents of .next/static
|
||||||
# prebuilt/public/ ← public/
|
# public/ ← public/
|
||||||
|
|
||||||
FROM node:22-alpine AS runner
|
FROM node:22-alpine AS runner
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
@@ -14,9 +14,9 @@ ENV HOSTNAME=0.0.0.0
|
|||||||
RUN addgroup --system --gid 1001 nodejs \
|
RUN addgroup --system --gid 1001 nodejs \
|
||||||
&& adduser --system --uid 1001 nextjs
|
&& adduser --system --uid 1001 nextjs
|
||||||
|
|
||||||
COPY --chown=nextjs:nodejs prebuilt/standalone/ ./
|
COPY --chown=nextjs:nodejs standalone/ ./
|
||||||
COPY --chown=nextjs:nodejs prebuilt/public ./public
|
COPY --chown=nextjs:nodejs public ./public
|
||||||
COPY --chown=nextjs:nodejs prebuilt/static ./.next/static
|
COPY --chown=nextjs:nodejs static ./.next/static
|
||||||
|
|
||||||
USER nextjs
|
USER nextjs
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user