diff --git a/.github/workflows/bld_docker.yml b/.github/workflows/bld_docker.yml index fb0bdb38e..70ba4bc01 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: @@ -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: @@ -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: @@ -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 }} diff --git a/Dockerfile.build.yarn b/Dockerfile.build.yarn new file mode 100644 index 000000000..8fff8b8fb --- /dev/null +++ b/Dockerfile.build.yarn @@ -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 + 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 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; + } + +} +