From c621ad7c967e26e52700f6b8aa6047274afe5c55 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 14:17:14 +0000 Subject: [PATCH 01/13] use registry cache for infinite cache size and expiry --- .github/workflows/bld_docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index fb0bdb38e..f1b19d212 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -164,8 +164,8 @@ jobs: push: true tags: ${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name}}:${{ steps.version.outputs.version_tag_numeric }} context: ${{ inputs.context }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache + cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache build-args: ${{ matrix.build_args }} file: ${{ steps.dynamic_defaults.outputs.default_file }} From 7387bf652a81054bf7ee4b4c4461555ab53a2966 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 14:18:50 +0000 Subject: [PATCH 02/13] migrate docker builds to more cacheable yarn style build with nginx --- .github/workflows/bld_docker.yml | 8 ++++---- Dockerfile.build.yarn | 30 ++++++++++++++++++++++++++++++ docker-compose.build.yarn.yml | 12 ++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.build.yarn create mode 100644 docker-compose.build.yarn.yml diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index f1b19d212..bf7ed6bb6 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -92,22 +92,22 @@ jobs: - artifact_name: prod docker_name: orcid/registry/orcid-web-frontend-prod build_args: "build_env=prod" - file: Dockerfile.build + file: Dockerfile.build.yarn - artifact_name: sandbox docker_name: orcid/registry/orcid-web-frontend-sandbox build_args: "build_env=sandbox" - file: Dockerfile.build + file: Dockerfile.build.yarn - artifact_name: qa docker_name: orcid/registry/orcid-web-frontend-qa build_args: "build_env=qa" - file: Dockerfile.build + file: Dockerfile.build.yarn - artifact_name: int docker_name: orcid/registry/orcid-web-frontend-int build_args: "build_env=int" - file: Dockerfile.build + file: Dockerfile.build.yarn runs-on: ubuntu-latest steps: diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn new file mode 100644 index 000000000..3c190f68c --- /dev/null +++ b/Dockerfile.build.yarn @@ -0,0 +1,30 @@ +FROM node:20.15.0-alpine AS build + +ARG build_env + +WORKDIR /app + +COPY package.json . + +RUN yarn install + +COPY *.json . + +COPY src/ src/ + +COPY scripts/ scripts/ + +RUN apk add gettext + +RUN yarn build:${build_env} + +FROM nginx:1.26.2-alpine + +RUN mkdir -p /usr/share/nginx/html/orcid-web-frontend + +COPY ./nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf + +COPY --from=build /app/dist/ /usr/share/nginx/html/orcid-web-frontend/ + +EXPOSE 80 + diff --git a/docker-compose.build.yarn.yml b/docker-compose.build.yarn.yml new file mode 100644 index 000000000..8979834c1 --- /dev/null +++ b/docker-compose.build.yarn.yml @@ -0,0 +1,12 @@ +version: '2' +services: + angular_yarn: + image: ${DOCKER_REG_PRIVATE}/orcid/registry/orcid-web-frontend-${BUILD_ENV:-qa}:${TAG:-0.0.1} + # entrypoint: sleep infinity + build: + context: . + dockerfile: Dockerfile.build.yarn + args: + build_env: ${BUILD_ENV:-qa} + ports: + - 0.0.0.0:13106:80 From d6dabe263b7681b4281c390a9f6dc1edc2e6f258 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 14:21:55 +0000 Subject: [PATCH 03/13] make docker push optional --- .github/workflows/bld_docker.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index bf7ed6bb6..be6fd1cab 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -44,6 +44,11 @@ on: required: false default: "default" type: string + push: + description: 'Select to push to docker registry' + required: false + default: true + type: boolean workflow_dispatch: inputs: @@ -82,7 +87,11 @@ on: required: false default: "default" type: string - + push: + description: 'Select to push to docker registry' + required: false + default: true + type: boolean jobs: bld_docker: @@ -161,7 +170,7 @@ jobs: - uses: docker/build-push-action@v6 with: - push: true + push: ${{ inputs.push }} tags: ${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name}}:${{ steps.version.outputs.version_tag_numeric }} context: ${{ inputs.context }} cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache From fd3a8878eef46e4c20822ff673022c80eaa9b0b2 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 14:29:41 +0000 Subject: [PATCH 04/13] add missing nginx config for new container --- nginx/conf.d/default.conf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 nginx/conf.d/default.conf diff --git a/nginx/conf.d/default.conf b/nginx/conf.d/default.conf new file mode 100644 index 000000000..957735d74 --- /dev/null +++ b/nginx/conf.d/default.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name _; + + # redirect language code dirs to an index.html dir + # + if (!-f $request_filename) { + rewrite "^\/orcid-web-frontend\/([a-z]{2}(_[A-Za-z]{2})?)\/.*" /orcid-web-frontend/$1/index.html last; + } + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + +} + From ee1b4fa3eb1897af2ba66294e4aa213744000edd Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 20:53:22 +0000 Subject: [PATCH 05/13] match yarn commands to other build --- Dockerfile.build.yarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index 3c190f68c..1805b7ae8 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -6,7 +6,7 @@ WORKDIR /app COPY package.json . -RUN yarn install +RUN yarn COPY *.json . From 42c5f4ce9274f261ecb8f77897e8ab4b460ad3e9 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 23:19:36 +0000 Subject: [PATCH 06/13] remove second cache statement and make yarn command clearer --- .github/workflows/bld_docker.yml | 10 +--------- Dockerfile.build.yarn | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index be6fd1cab..70ba4bc01 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -142,15 +142,7 @@ jobs: bump: ${{ inputs.bump }} - uses: docker/setup-buildx-action@v3 - - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - # each cache needs a unique key for the job - key: ${{ runner.os }}-buildx-${{ hashFiles(inputs.context) }} - # Alternative restore keys if no exact match is found - # I /think/ this means that other docker buildx jobs could help out here - restore-keys: | - ${{ runner.os }}-buildx- + - name: Login to private registry uses: docker/login-action@v3 with: diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index 1805b7ae8..766a789dd 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -6,7 +6,7 @@ WORKDIR /app COPY package.json . -RUN yarn +RUN yarn install --frozen-lockfile COPY *.json . From 09781da741ec74df900a46fa56929b0a678645bb Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 23:36:50 +0000 Subject: [PATCH 07/13] attempt to lockdown docker buildx version --- .github/workflows/bld_docker.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index 70ba4bc01..b21bd60e2 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -142,6 +142,8 @@ jobs: bump: ${{ inputs.bump }} - uses: docker/setup-buildx-action@v3 + with: + version: v0.16.1 - name: Login to private registry uses: docker/login-action@v3 From cace79abc2dd07b8bb9d2225565397cbd557ed80 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Mon, 25 Nov 2024 23:42:11 +0000 Subject: [PATCH 08/13] missing yarn lock in container --- Dockerfile.build.yarn | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index 766a789dd..ca0811a86 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -6,6 +6,8 @@ WORKDIR /app COPY package.json . +COPY yarn.lock . + RUN yarn install --frozen-lockfile COPY *.json . From ff85a81d36906d46f450f023cb38756c875d2ee0 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Tue, 26 Nov 2024 00:07:17 +0000 Subject: [PATCH 09/13] use npm direct --- Dockerfile.build.yarn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index ca0811a86..527ffd697 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -18,7 +18,7 @@ COPY scripts/ scripts/ RUN apk add gettext -RUN yarn build:${build_env} +RUN npm run build:${build_env} FROM nginx:1.26.2-alpine From 6253d48c58bc85959bfc6ce013f9fa649148d69c Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Tue, 26 Nov 2024 11:39:29 +0000 Subject: [PATCH 10/13] try node downgrade --- Dockerfile.build.yarn | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index 527ffd697..d4cef904b 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -1,4 +1,5 @@ -FROM node:20.15.0-alpine AS build +#FROM node:20.15.0-alpine AS build +FROM node:19.9.0-alpine AS build ARG build_env From 8d63de9258723b2b31a87e1c555bb78457b6cf7d Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Tue, 26 Nov 2024 17:31:46 +0000 Subject: [PATCH 11/13] bump build node version --- Dockerfile.build.yarn | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn index d4cef904b..8fff8b8fb 100644 --- a/Dockerfile.build.yarn +++ b/Dockerfile.build.yarn @@ -1,5 +1,7 @@ #FROM node:20.15.0-alpine AS build -FROM node:19.9.0-alpine AS build +#FROM node:18.19.1-bullseye AS build +FROM node:22.11.0-bullseye AS build +#FROM node:16.14.0-bullseye AS build ARG build_env @@ -7,9 +9,7 @@ WORKDIR /app COPY package.json . -COPY yarn.lock . - -RUN yarn install --frozen-lockfile +RUN yarn COPY *.json . @@ -17,11 +17,12 @@ COPY src/ src/ COPY scripts/ scripts/ -RUN apk add gettext +# RUN apk add gettext -RUN npm run build:${build_env} +RUN yarn build:${build_env} FROM nginx:1.26.2-alpine +#FROM nginx:1.26.2-bookworm RUN mkdir -p /usr/share/nginx/html/orcid-web-frontend From 0a6ce4fe803f3788d22fcc1f9d3d6a804d76a849 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Tue, 26 Nov 2024 18:46:15 +0000 Subject: [PATCH 12/13] match config to forked repo --- .github/workflows/bld_docker.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index b21bd60e2..aa2f92201 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -142,8 +142,6 @@ jobs: bump: ${{ inputs.bump }} - uses: docker/setup-buildx-action@v3 - with: - version: v0.16.1 - name: Login to private registry uses: docker/login-action@v3 @@ -167,8 +165,8 @@ jobs: push: ${{ inputs.push }} tags: ${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name}}:${{ steps.version.outputs.version_tag_numeric }} context: ${{ inputs.context }} - cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache - cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache +# cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache +# cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache build-args: ${{ matrix.build_args }} file: ${{ steps.dynamic_defaults.outputs.default_file }} From a7efa36e932c1783bae4f96d440f50fa57d98055 Mon Sep 17 00:00:00 2001 From: Giles Westwood Date: Tue, 26 Nov 2024 19:08:20 +0000 Subject: [PATCH 13/13] re-enable caching --- .github/workflows/bld_docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index aa2f92201..70ba4bc01 100644 --- a/.github/workflows/bld_docker.yml +++ b/.github/workflows/bld_docker.yml @@ -165,8 +165,8 @@ jobs: push: ${{ inputs.push }} tags: ${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name}}:${{ steps.version.outputs.version_tag_numeric }} context: ${{ inputs.context }} -# cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache -# cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache + cache-from: type=registry,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache + cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ secrets.DOCKER_REG_PRIVATE }}/${{ matrix.docker_name }}:cache build-args: ${{ matrix.build_args }} file: ${{ steps.dynamic_defaults.outputs.default_file }}