From de76c14c59bb533af81931d7356ddfab4d8039a7 Mon Sep 17 00:00:00 2001 From: Darian Date: Thu, 24 Sep 2026 15:51:43 +0330 Subject: [PATCH] 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. --- .github/workflows/deploy.yml | 25 ++++++++++++++++++++++--- Dockerfile.prebuilt | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 26f03c5..3a1c4b0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -104,17 +104,36 @@ jobs: - name: Verify artifact & build image run: | set -euo pipefail + echo "== artifact root ==" + ls -la prebuilt + echo "== artifact .next ==" + ls -la prebuilt/.next + test -f prebuilt/server.js test -f prebuilt/.next/BUILD_ID test -d prebuilt/.next/static test -d prebuilt/node_modules test -f prebuilt/Dockerfile + # Drop legacy root static from context if present (Next deprecation) + rm -rf prebuilt/static + docker build -t "$IMAGE_NAME" prebuilt - # Confirm BUILD_ID is actually inside the image - 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' + echo "== image checks ==" + docker run --rm --entrypoint sh "$IMAGE_NAME" -c ' + 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 env: diff --git a/Dockerfile.prebuilt b/Dockerfile.prebuilt index c5db2a1..2db5867 100644 --- a/Dockerfile.prebuilt +++ b/Dockerfile.prebuilt @@ -15,6 +15,9 @@ RUN addgroup --system --gid 1001 nodejs \ # Single COPY of an already-complete app root (avoids missing hidden .next) COPY --chown=nextjs:nodejs . ./ +# Next warns/breaks if a legacy root-level ./static exists alongside ./public +RUN rm -rf ./static + USER nextjs EXPOSE 3000 CMD ["node", "server.js"]