From 68fdc3a9f3b741a141a6373620b0031bd00a0a02 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 30 Nov 2020 18:03:22 +0100 Subject: [PATCH 1/2] backend: remove yarn cache from built docker image --- .changeset/beige-queens-crash.md | 13 +++++++++++++ packages/backend/Dockerfile | 2 +- .../default-app/packages/backend/Dockerfile | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/beige-queens-crash.md diff --git a/.changeset/beige-queens-crash.md b/.changeset/beige-queens-crash.md new file mode 100644 index 0000000000..7bc2e2da94 --- /dev/null +++ b/.changeset/beige-queens-crash.md @@ -0,0 +1,13 @@ +--- +'@backstage/create-app': patch +--- + +Optimized the `yarn install` step in the backend `Dockerfile`. + +To apply these changes to an existing app, make the following changes to `packages/backend/Dockerfile`: + +Replace the `RUN yarn install ...` line with the following: + +```bash +RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" +``` diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index 93929ceb86..165fd021ff 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /usr/src/app # and along with yarn.lock and the root package.json, that's enough to run yarn install. ADD yarn.lock package.json skeleton.tar ./ -RUN yarn install --frozen-lockfile --production +RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" # This will copy the contents of the dist-workspace when running the build-image command. # Do not use this Dockerfile outside of that command, as it will copy in the source code instead. diff --git a/packages/create-app/templates/default-app/packages/backend/Dockerfile b/packages/create-app/templates/default-app/packages/backend/Dockerfile index 0fcd23f0e1..58f522adc9 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /usr/src/app # and along with yarn.lock and the root package.json, that's enough to run yarn install. ADD yarn.lock package.json skeleton.tar ./ -RUN yarn install --frozen-lockfile --production +RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" # This will copy the contents of the dist-workspace when running the build-image command. # Do not use this Dockerfile outside of that command, as it will copy in the source code instead. From a5687a6c5ea5a3e2c1d17e334c2fe3f25a0c879a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 30 Nov 2020 18:39:49 +0100 Subject: [PATCH 2/2] backend,yarnrc: bring yarn network-timeout down to 300s --- .changeset/beige-queens-crash.md | 2 +- .yarnrc | 2 +- packages/backend/Dockerfile | 2 +- .../templates/default-app/packages/backend/Dockerfile | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.changeset/beige-queens-crash.md b/.changeset/beige-queens-crash.md index 7bc2e2da94..6253717673 100644 --- a/.changeset/beige-queens-crash.md +++ b/.changeset/beige-queens-crash.md @@ -9,5 +9,5 @@ To apply these changes to an existing app, make the following changes to `packag Replace the `RUN yarn install ...` line with the following: ```bash -RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" +RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" ``` diff --git a/.yarnrc b/.yarnrc index 6b56b971d7..4cdaac2408 100644 --- a/.yarnrc +++ b/.yarnrc @@ -6,4 +6,4 @@ registry "https://registry.npmjs.org/" disable-self-update-check true lastUpdateCheck 1580389148099 yarn-path ".yarn/releases/yarn-1.22.1.js" -network-timeout 600000 +network-timeout 300000 diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index 165fd021ff..1aa5a355cf 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /usr/src/app # and along with yarn.lock and the root package.json, that's enough to run yarn install. ADD yarn.lock package.json skeleton.tar ./ -RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" +RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" # This will copy the contents of the dist-workspace when running the build-image command. # Do not use this Dockerfile outside of that command, as it will copy in the source code instead. diff --git a/packages/create-app/templates/default-app/packages/backend/Dockerfile b/packages/create-app/templates/default-app/packages/backend/Dockerfile index 58f522adc9..50514713d3 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /usr/src/app # and along with yarn.lock and the root package.json, that's enough to run yarn install. ADD yarn.lock package.json skeleton.tar ./ -RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" +RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" # This will copy the contents of the dist-workspace when running the build-image command. # Do not use this Dockerfile outside of that command, as it will copy in the source code instead.