From b8991f64be69af1728380f90344c47e1d4b39581 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 19 Aug 2022 16:36:46 +0200 Subject: [PATCH] update in-repo Docker setup to use Yarn 3 Signed-off-by: Patrik Oldsberg --- .dockerignore | 2 ++ packages/backend/Dockerfile | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 45f9f52059..e43b5fab1e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,6 @@ .git +.yarn/cache +.yarn/install-state.gz docs cypress microsite diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index ed18da530b..7ed0121467 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -25,13 +25,18 @@ WORKDIR /app # This switches many Node.js dependencies to production mode. ENV NODE_ENV production +# Copy over Yarn 3 configuration, release, and plugins +COPY .yarn ./.yarn +COPY .yarnrc.yml ./ + # Copy repo skeleton first, to avoid unnecessary docker cache invalidation. # The skeleton contains the package.json of each package in the monorepo, # and along with yarn.lock and the root package.json, that's enough to run yarn install. COPY --chown=node:node yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz -RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" +# Note that this install is not immutable, which is one of the reasons we don't recommend Yarn 3 yet +RUN yarn workspaces focus --all --production && rm -rf "$(yarn cache clean)" # Then copy the rest of the backend bundle, along with any other files we might want. COPY --chown=node:node packages/backend/dist/bundle.tar.gz app-config*.yaml ./