fix: frontend Dockerfile for production

This commit is contained in:
Mohamed Marrouchi 2024-10-04 06:43:41 +01:00
parent 5df35d94f7
commit 5fe4726495

View File

@ -62,7 +62,7 @@ CMD ["npm", "run", "dev", "--", "-p", "8080"]
# Production image, copy all the files and run next # Production image, copy all the files and run next
FROM base AS production FROM base AS production
WORKDIR /app/frontend WORKDIR /app
ENV NODE_ENV=production ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime. # Uncomment the following line in case you want to disable telemetry during runtime.
@ -71,18 +71,17 @@ ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs RUN adduser --system --uid 1001 nextjs
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/frontend/.next/standalone/frontend ./
COPY --from=builder --chown=nextjs:nodejs /app/frontend/.next/static ./.next/static
COPY --from=builder /app/node_modules ./node_modules COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/frontend/public ./public COPY --from=builder /app/frontend/public ./public
# Set the correct permission for prerender cache # Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next RUN chown nextjs:nodejs .next
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/frontend/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/frontend/.next/static ./.next/static
USER nextjs USER nextjs
EXPOSE 8080 EXPOSE 8080