Fix Next.js standalone build in Docker
This commit is contained in:
parent
a85f4c0cdc
commit
afe5528a1b
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user