Remove legacy static directory from Dockerfile and deployment workflow to prevent Next.js warnings. Updated verification steps in GitHub Actions to ensure the absence of the static directory in the built image.

This commit is contained in:
smhk1376 committed 2026-09-24 15:51:43 +03:30
1 parent 19fe962143
commit de76c14c59
2 files changed
+25 -3

No files matched your search

+22 -3
View File
@@ -104,17 +104,36 @@ jobs:
- name: Verify artifact & build image - name: Verify artifact & build image
run: | run: |
set -euo pipefail set -euo pipefail
echo "== artifact root =="
ls -la prebuilt
echo "== artifact .next =="
ls -la prebuilt/.next
test -f prebuilt/server.js test -f prebuilt/server.js
test -f prebuilt/.next/BUILD_ID test -f prebuilt/.next/BUILD_ID
test -d prebuilt/.next/static test -d prebuilt/.next/static
test -d prebuilt/node_modules test -d prebuilt/node_modules
test -f prebuilt/Dockerfile test -f prebuilt/Dockerfile
# Drop legacy root static from context if present (Next deprecation)
rm -rf prebuilt/static
docker build -t "$IMAGE_NAME" prebuilt docker build -t "$IMAGE_NAME" prebuilt
# Confirm BUILD_ID is actually inside the image echo "== image checks =="
docker run --rm --entrypoint sh "$IMAGE_NAME" -c \ docker run --rm --entrypoint sh "$IMAGE_NAME" -c '
'test -f /app/.next/BUILD_ID && test -f /app/server.js && test -d /app/.next/static && test ! -e /app/static && ls -la /app && ls -la /app/.next' set -e
ls -la /app
ls -la /app/.next
test -f /app/server.js || { echo "FAIL: missing /app/server.js"; exit 1; }
test -f /app/.next/BUILD_ID || { echo "FAIL: missing /app/.next/BUILD_ID"; exit 1; }
test -d /app/.next/static || { echo "FAIL: missing /app/.next/static"; exit 1; }
if [ -e /app/static ]; then
echo "FAIL: legacy /app/static still present"
exit 1
fi
echo "OK: runtime files present"
'
- name: Restart container - name: Restart container
env: env:
+3
View File
@@ -15,6 +15,9 @@ RUN addgroup --system --gid 1001 nodejs \
# Single COPY of an already-complete app root (avoids missing hidden .next) # Single COPY of an already-complete app root (avoids missing hidden .next)
COPY --chown=nextjs:nodejs . ./ COPY --chown=nextjs:nodejs . ./
# Next warns/breaks if a legacy root-level ./static exists alongside ./public
RUN rm -rf ./static
USER nextjs USER nextjs
EXPOSE 3000 EXPOSE 3000
CMD ["node", "server.js"] CMD ["node", "server.js"]