From 730bf5826978bc690a39029b6c57bc62a6261e61 Mon Sep 17 00:00:00 2001 From: David Glymph Date: Tue, 6 Jun 2023 10:39:53 -0400 Subject: [PATCH] copy package-json & just next folder for reduced image size --- Dockerfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94cd0de..fbdf600 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -22,7 +23,6 @@ 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 @@ -30,6 +30,10 @@ 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