From 9c078ab5d2716ced030676f718dffbf59e1a99d3 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 3 Dec 2021 15:36:08 +0100 Subject: [PATCH] fix: update npm calls to handle workspaces (#44370) * fix: use workspaces for crowdin npm ci * fix: update server.Dockerfile to use workspaces * fix: update client.Dockerfile to use workspaces --- .github/workflows/crowdin-i18n-client-ui-download.yml | 5 +---- .github/workflows/crowdin-i18n-curriculum-download.yml | 5 +---- .github/workflows/crowdin-i18n-curriculum-upload.yml | 5 +---- .github/workflows/crowdin-i18n-docs.download.yml | 5 +---- client.Dockerfile | 4 ++-- server.Dockerfile | 10 ++++------ 6 files changed, 10 insertions(+), 24 deletions(-) diff --git a/.github/workflows/crowdin-i18n-client-ui-download.yml b/.github/workflows/crowdin-i18n-client-ui-download.yml index 5101704fb6..bf9b2fa19d 100644 --- a/.github/workflows/crowdin-i18n-client-ui-download.yml +++ b/.github/workflows/crowdin-i18n-client-ui-download.yml @@ -17,10 +17,7 @@ jobs: token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} - name: Install Dependencies - working-directory: ./tools - run: | - cd ./crowdin - npm ci + run: npm ci -w=tools/crowdin --ignore-scripts ##### Download Chinese ##### - name: Crowdin Download Chinese Translations diff --git a/.github/workflows/crowdin-i18n-curriculum-download.yml b/.github/workflows/crowdin-i18n-curriculum-download.yml index be1cc3c607..320a7766a2 100644 --- a/.github/workflows/crowdin-i18n-curriculum-download.yml +++ b/.github/workflows/crowdin-i18n-curriculum-download.yml @@ -17,10 +17,7 @@ jobs: token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} - name: Install Dependencies - working-directory: ./tools - run: | - cd ./crowdin - npm ci + run: npm ci -w=tools/crowdin --ignore-scripts ##### Download Chinese ##### - name: Crowdin Download Chinese Translations diff --git a/.github/workflows/crowdin-i18n-curriculum-upload.yml b/.github/workflows/crowdin-i18n-curriculum-upload.yml index a9d8c5bb85..891574cc8c 100644 --- a/.github/workflows/crowdin-i18n-curriculum-upload.yml +++ b/.github/workflows/crowdin-i18n-curriculum-upload.yml @@ -15,10 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Install Dependencies - working-directory: ./tools - run: | - cd ./crowdin - npm ci + run: npm ci -w=tools/crowdin --ignore-scripts - name: Crowdin Upload uses: crowdin/github-action@master diff --git a/.github/workflows/crowdin-i18n-docs.download.yml b/.github/workflows/crowdin-i18n-docs.download.yml index ac8adc8224..4b0b24bbbd 100644 --- a/.github/workflows/crowdin-i18n-docs.download.yml +++ b/.github/workflows/crowdin-i18n-docs.download.yml @@ -17,10 +17,7 @@ jobs: token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }} - name: Install Dependencies - working-directory: ./tools - run: | - cd ./crowdin - npm ci + run: npm ci -w=tools/crowdin --ignore-scripts ##### Download Chinese ##### - name: Crowdin Download Chinese Translations diff --git a/client.Dockerfile b/client.Dockerfile index 5111764d04..8e69c4738b 100644 --- a/client.Dockerfile +++ b/client.Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.18.2-buster AS builder +FROM node:16-buster AS builder # this is a bit clunky, perhaps there's a more concise way of passing in build # arguments @@ -28,7 +28,7 @@ RUN npm run build:client WORKDIR /home/node/config RUN git clone https://github.com/freeCodeCamp/client-config.git client -FROM node:14.18.2-alpine +FROM node:16-alpine RUN npm i -g serve USER node WORKDIR /home/node diff --git a/server.Dockerfile b/server.Dockerfile index 2ed93e1b9a..7c9d5d87ba 100644 --- a/server.Dockerfile +++ b/server.Dockerfile @@ -1,4 +1,4 @@ -FROM node:14.18.2-alpine as builder +FROM node:16-alpine as builder USER node WORKDIR /home/node/build COPY --chown=node:node . . @@ -7,15 +7,13 @@ RUN npm ci --no-progress RUN npm run build:curriculum RUN npm run build:server -FROM node:14.18.2-alpine +FROM node:16-alpine USER node WORKDIR /home/node/api # get and install deps COPY --from=builder --chown=node:node /home/node/build/package.json /home/node/build/package-lock.json ./ -COPY --from=builder --chown=node:node /home/node/build/api-server/package.json /home/node/build/api-server/package-lock.json api-server/ -RUN npm ci --production --ignore-scripts --no-progress \ - && cd api-server \ - && npm ci --production --no-progress \ +COPY --from=builder --chown=node:node /home/node/build/api-server/package.json api-server/ +RUN npm ci --production -w=api-server --include-workspace-root --no-progress --ignore-scripts \ && npm cache clean --force COPY --from=builder --chown=node:node /home/node/build/api-server/lib/ api-server/lib/ COPY --from=builder --chown=node:node /home/node/build/utils/ utils/