From a65aeaaf87515f62e21205e56eeeb60627ecba49 Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 23 May 2024 10:01:43 -0400 Subject: [PATCH] fix: docker runtime for nextjs --- apps/web/next.config.js | 1 + docker/Dockerfile | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 1381f4f..d6bdabf 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -18,6 +18,7 @@ const nextConfig = { "@mychat/tailwind-config", "@mychat/eslint-config", "@mychat/tsconfig", + "@mychat/ui", ], /** We already do linting and typechecking as separate tasks in CI */ diff --git a/docker/Dockerfile b/docker/Dockerfile index c705135..a0ef102 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -22,22 +22,22 @@ RUN bun install RUN bun run build:web ## Runner -FROM base AS runner +FROM node:21-alpine AS runner WORKDIR /web/ ENV NODE_ENV=production -ENV CLIENT_BUILD_DIR=web # Don't run production as root RUN addgroup --system --gid 1001 nodejs -USER bun +RUN adduser --system --uid 1001 --ingroup nodejs nextjs +USER nextjs COPY --from=builder /web/apps/web/next.config.js . COPY --from=builder /web/apps/web/package.json . # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing -COPY --from=builder --chown=bun:nodejs /web/apps/web/.next/standalone ./ -COPY --from=builder --chown=bun:nodejs /web/apps/web/.next/static ./apps/web/.next/static -COPY --from=builder --chown=bun:nodejs /web/apps/web/public ./apps/web/public +COPY --from=builder --chown=nextjs:nodejs /web/apps/web/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /web/apps/web/.next/static ./apps/web/.next/static +COPY --from=builder --chown=nextjs:nodejs /web/apps/web/public ./apps/web/public -CMD bun apps/web/server.js \ No newline at end of file +CMD node apps/web/server.js \ No newline at end of file