From 5b187f650cb9a906bdc7acc5eb3835c58227e58a Mon Sep 17 00:00:00 2001 From: borja-rivera Date: Wed, 16 Jul 2025 15:12:54 +0200 Subject: [PATCH 1/2] update Dockerfile to build distroless image --- Dockerfile | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 305a4acf7..35b446474 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,31 +41,27 @@ RUN npm run build RUN npm run build-standalone RUN npm run post-build-standalone -# Production image, copy all the files and run next -FROM base AS runner +# Production image as distroless, copy all the files and run next +FROM gcr.io/distroless/nodejs18:nonroot AS runner WORKDIR /app ENV NODE_ENV production # Uncomment the following line in case you want to disable telemetry during runtime. ENV NEXT_TELEMETRY_DISABLED 1 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs COPY --from=builder /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/src/__generated__/ ./src/__generated__/ -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static +COPY --from=builder /app/src/__generated__/ ./src/__generated__ +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static -USER nextjs +ENV CADENCE_WEB_PORT=8088 +EXPOSE 8088 -CMD ["sh","-c", "CADENCE_WEB_PORT=${CADENCE_WEB_PORT:-8088} CADENCE_WEB_HOSTNAME=${CADENCE_WEB_HOSTNAME:-0.0.0.0} exec node server.js"] +CMD ["server.js"] From 47403d39b9399d0cd5238594e379c4ca9a9f8611 Mon Sep 17 00:00:00 2001 From: borja-rivera <144139650+borja-rivera@users.noreply.github.com> Date: Thu, 17 Jul 2025 10:07:39 +0200 Subject: [PATCH 2/2] add CADENCE_WEB_HOSTNAME --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 35b446474..d6db2afbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,7 @@ COPY --from=builder /app/.next/standalone ./ COPY --from=builder /app/.next/static ./.next/static ENV CADENCE_WEB_PORT=8088 +ENV CADENCE_WEB_HOSTNAME=0.0.0.0 EXPOSE 8088