Skip to content

Commit

Permalink
copy package-json & just next folder for reduced image size
Browse files Browse the repository at this point in the history
  • Loading branch information
Woozl committed Jun 6, 2023
1 parent 459c462 commit 730bf58
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ FROM base AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY package.json package-lock.json*
COPY package.json .
COPY package-lock.json .
RUN npm ci

# Rebuild the source code only when needed
Expand All @@ -22,14 +23,17 @@ RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
COPY . .

ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json

USER nextjs

EXPOSE 3000
Expand Down

0 comments on commit 730bf58

Please sign in to comment.