Skip to content

Commit

Permalink
Merge pull request #2405 from ORCID/feat/yarn-docker-container-regist…
Browse files Browse the repository at this point in the history
…ry-caching

feat/yarn-docker-container-registry-caching
  • Loading branch information
gilesw authored Nov 28, 2024
2 parents 43f0b0c + bdfef21 commit c4a54d2
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 17 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/bld_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -92,22 +101,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:
Expand All @@ -133,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:
Expand All @@ -161,11 +162,11 @@ 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=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 }}

34 changes: 34 additions & 0 deletions Dockerfile.build.yarn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#FROM node:20.15.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

WORKDIR /app

COPY package.json .

RUN yarn

COPY *.json .

COPY src/ src/

COPY scripts/ scripts/

# RUN apk add gettext

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

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

12 changes: 12 additions & 0 deletions docker-compose.build.yarn.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit c4a54d2

Please sign in to comment.