From afe5528a1b5fba0c4a5ef11d0579c34534713770 Mon Sep 17 00:00:00 2001 From: yznahmad Date: Fri, 20 Jun 2025 02:59:38 +0300 Subject: [PATCH] Fix Next.js standalone build in Docker --- webapp/Dockerfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 2098f92..4a99c9b 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -11,11 +11,7 @@ RUN npm ci COPY webapp/ . # Set environment variables for build -# Use a dummy DB_URI during build to prevent connection attempts -ENV DB_URI="mongodb://dummy:password@localhost:27017/dummy" ENV NODE_ENV=production - -# Disable Next.js telemetry during build ENV NEXT_TELEMETRY_DISABLED=1 # Build the application @@ -33,10 +29,13 @@ RUN addgroup --system --gid 1001 nodejs RUN adduser --system --uid 1001 nextjs # Copy the built application from the builder stage +COPY --from=deps /app/next.config.js . COPY --from=deps /app/public ./public +COPY --from=deps /app/package.json ./package.json -# Automatically leverage output traces to reduce image size +# Copy .next/standalone COPY --from=deps --chown=nextjs:nodejs /app/.next/standalone ./ +# Copy .next/static COPY --from=deps --chown=nextjs:nodejs /app/.next/static ./.next/static # Set the user to non-root