From d29d2b6a17950d3079242dd9cd0d2d5293b464fa Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Thu, 3 Jul 2025 14:59:36 +0530 Subject: [PATCH 1/2] feat: optimize docker builds for live server --- apps/live/Dockerfile.live | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/live/Dockerfile.live b/apps/live/Dockerfile.live index ae9eba9d14e..776a2ef3ca1 100644 --- a/apps/live/Dockerfile.live +++ b/apps/live/Dockerfile.live @@ -2,6 +2,9 @@ FROM node:20-alpine AS base # The web Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker. # Make sure you update this Dockerfile, the Dockerfile in the web workspace and copy that over to Dockerfile in the docs. +# ***************************************************************************** +# STAGE 1: Prune the project +# ***************************************************************************** FROM base AS builder # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk update @@ -12,6 +15,9 @@ RUN yarn global add turbo COPY . . RUN turbo prune live --docker +# ***************************************************************************** +# STAGE 2: Install dependencies & build the project +# ***************************************************************************** # Add lockfile and package.json's of isolated subworkspace FROM base AS installer RUN apk update @@ -28,16 +34,22 @@ RUN yarn install COPY --from=builder /app/out/full/ . COPY turbo.json turbo.json -ENV TURBO_TELEMETRY_DISABLED 1 +ENV TURBO_TELEMETRY_DISABLED=1 RUN yarn turbo build --filter=live +# ***************************************************************************** +# STAGE 3: Run the project +# ***************************************************************************** + FROM base AS runner WORKDIR /app -COPY --from=installer /app . -# COPY --from=installer /app/live/node_modules ./node_modules +COPY --from=installer /app/packages ./packages +COPY --from=installer /app/apps/live/dist ./live +COPY --from=installer /app/apps/live/package.json ./package.json +COPY --from=installer /app/node_modules ./node_modules -ENV TURBO_TELEMETRY_DISABLED 1 +ENV TURBO_TELEMETRY_DISABLED=1 EXPOSE 3000 From 252bc44ee8b6bc5e9e201164ade1b906698a6ad5 Mon Sep 17 00:00:00 2001 From: sriramveeraghanta Date: Thu, 3 Jul 2025 18:20:15 +0530 Subject: [PATCH 2/2] chore: removed package.json from dockerfile --- apps/live/Dockerfile.live | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/live/Dockerfile.live b/apps/live/Dockerfile.live index 776a2ef3ca1..5bec2624cc9 100644 --- a/apps/live/Dockerfile.live +++ b/apps/live/Dockerfile.live @@ -47,7 +47,6 @@ WORKDIR /app COPY --from=installer /app/packages ./packages COPY --from=installer /app/apps/live/dist ./live -COPY --from=installer /app/apps/live/package.json ./package.json COPY --from=installer /app/node_modules ./node_modules ENV TURBO_TELEMETRY_DISABLED=1