diff --git a/Dockerfile b/Dockerfile index a85dcf9..10a8cf9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,10 +62,18 @@ ENV HOSTNAME=0.0.0.0 RUN addgroup --system --gid 1001 nodejs && \ adduser --system --uid 1001 nextjs -# Copy the standalone build (Next.js output tracing) + static assets -COPY --from=builder /app/public ./public +# Copy the standalone build (Next.js output tracing) + static assets. +# `public/` is optional (PWA manifest, favicons, robots.txt). Next +# inlines any source `public/` into the standalone build, so we only +# need to copy it if it actually exists. Projects without a public/ +# dir (e.g. this one pre-PWA) no-op cleanly. COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +RUN if [ -d ./public ] && [ -n "$(ls -A ./public 2>/dev/null)" ]; then \ + echo "public/ assets found in standalone build, keeping"; \ + else \ + rm -rf ./public 2>/dev/null || true; \ + fi USER nextjs EXPOSE 3000