|
| 1 | +FROM node:22-alpine AS base |
| 2 | + |
| 3 | +# The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker. |
| 4 | +# Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs. |
| 5 | + |
| 6 | +FROM base AS builder |
| 7 | +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. |
| 8 | +RUN apk update |
| 9 | +RUN apk add --no-cache libc6-compat |
| 10 | +# Set working directory |
| 11 | +WORKDIR /contwatch-client |
| 12 | +RUN npm install turbo |
| 13 | +COPY . . |
| 14 | +RUN npx turbo prune contwatch-client --docker |
| 15 | + |
| 16 | +# Add lockfile and package.json's of isolated subworkspace |
| 17 | +FROM base AS installer |
| 18 | +RUN apk update |
| 19 | +RUN apk add --no-cache libc6-compat |
| 20 | +WORKDIR /contwatch-client |
| 21 | + |
| 22 | +# First install dependencies (as they change less often) |
| 23 | +COPY --from=builder /contwatch-client/out/json/ . |
| 24 | +RUN npm install |
| 25 | + |
| 26 | +# Build the project and its dependencies |
| 27 | +COPY --from=builder /contwatch-client/out/full/ . |
| 28 | + |
| 29 | +# Uncomment and use build args to enable remote caching |
| 30 | +# ARG TURBO_TEAM |
| 31 | +# ENV TURBO_TEAM=$TURBO_TEAM |
| 32 | + |
| 33 | +# ARG TURBO_TOKEN |
| 34 | +# ENV TURBO_TOKEN=$TURBO_TOKEN |
| 35 | + |
| 36 | +RUN npx turbo build --filter=contwatch-client... |
| 37 | + |
| 38 | +FROM base AS runner |
| 39 | +WORKDIR /contwatch-client |
| 40 | + |
| 41 | +# Don't run production as root |
| 42 | +RUN addgroup --system --gid 1001 nodejs |
| 43 | +RUN adduser --system --uid 1001 nextjs |
| 44 | +USER nextjs |
| 45 | + |
| 46 | +COPY --from=installer --chown=nextjs:nodejs /contwatch-client/apps/contwatch-client/.next/standalone ./ |
| 47 | +COPY --from=installer --chown=nextjs:nodejs /contwatch-client/apps/contwatch-client/.next/static ./apps/contwatch-client/.next/static |
| 48 | +COPY --from=installer --chown=nextjs:nodejs /contwatch-client/apps/contwatch-client/public ./apps/contwatch-client/public |
| 49 | + |
| 50 | +CMD node apps/contwatch-client/server.js |
0 commit comments