Skip to content

Commit

Permalink
fix: docker runtime for nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1230 committed May 23, 2024
1 parent 44108fb commit a65aeaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
14 changes: 7 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
CMD node apps/web/server.js

0 comments on commit a65aeaa

Please sign in to comment.