From dfe0fef06e5a95312c06fe66b8b56c9d81365839 Mon Sep 17 00:00:00 2001 From: Bret Hubbard Date: Wed, 5 Oct 2022 10:19:16 -0600 Subject: [PATCH] add instructions for a multi-stage build dockerfile Signed-off-by: Bret Hubbard --- docs/tutorials/yarn-migration.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/tutorials/yarn-migration.md b/docs/tutorials/yarn-migration.md index 7f898c7b98..6dee343e78 100644 --- a/docs/tutorials/yarn-migration.md +++ b/docs/tutorials/yarn-migration.md @@ -67,6 +67,13 @@ COPY .yarn ./.yarn COPY .yarnrc.yml ./ ``` +In a multi-stage `Dockerfile`, each stage that runs a `yarn` command will also need the Yarn 3 installation. For example, in the final stage you may need to add the following: + +```Dockerfile +COPY --from=build --chown=node:node /app/.yarn ./.yarn +COPY --from=build --chown=node:node /app/.yarnrc.yml ./ +``` + The `--production` flag to `yarn install` has been removed in Yarn 3, instead you need to use `yarn workspaces focus --all --production` to avoid installing development dependencies in your production deployment. A tradeoff of this is that `yarn workspaces focus` does not support the `--immutable` flag. ```Dockerfile