Skip to content

Commit

Permalink
Refactor Dockerfile to simplify COPY commands
Browse files Browse the repository at this point in the history
  • Loading branch information
robinv8 committed Jan 1, 2024
1 parent e063bde commit 03a448b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM node:18-alpine AS runner

FROM node:18-alpine
WORKDIR /app

ENV NODE_ENV production
Expand All @@ -9,16 +8,16 @@ ENV NODE_ENV production
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public
COPY /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .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/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs /app/.next/standalone ./
COPY --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

Expand Down

0 comments on commit 03a448b

Please sign in to comment.