From 10c4aa4a435fe36cc4ded6f4d4f661bdf495bed5 Mon Sep 17 00:00:00 2001 From: leonardomeireles55 Date: Wed, 5 Feb 2025 09:22:35 -0300 Subject: [PATCH] improvements and fixes: clean up Dockerfile and .dockerignore for better build efficiency and user management --- .dockerignore | 10 ---------- Dockerfile | 24 +++++++----------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index 4db010a..4ff871c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,11 +9,6 @@ yarn-error.log* /coverage /test-results -# Next.js -/.next/ -/out/ -/build - # Environment files .env.local .env.development.local @@ -41,11 +36,6 @@ docker-compose.yml .DS_Store Thumbs.db -# Documentation and config -*.md -*.yml -*.yaml - # Misc .log /dist diff --git a/Dockerfile b/Dockerfile index 0b85d6e..a63dd44 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,22 +27,12 @@ WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -# RUN addgroup --system --gid 1001 nodejs -# RUN adduser --system --uid 1001 nextjs - -# COPY --from=builder /app/public ./public -# COPY --from=builder /app/.next ./_next -# COPY --from=builder /app/.next/standalone ./ -# COPY --from=builder /app/.next/static ./.next/static - -COPY --from=builder /app/.next/standalone ./ -COPY --from=builder /app/.next/static ./.next/static -COPY --from=builder /app/.next/static ./.next/standalone/.next/static -COPY --from=builder /app/public ./ +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + COPY --from=builder /app/public ./public -COPY --from=builder /app/.next/server ./.next/standalone/server -COPY --from=builder /app/.next/cache ./.next/standalone/cache -COPY --from=builder /app/.next/static ./_next/static -COPY --from=builder /app/.next ./_next +# COPY --chown=nextjs:nodejs --from=builder /app/.next ./_next +COPY --chown=nextjs:nodejs --from=builder /app/.next/standalone ./ +COPY --chown=nextjs:nodejs --from=builder /app/.next/static ./.next/static -# USER nextjs +USER nextjs