refactor: Update Dockerfile to conditionally install npm dependencies… #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish images | |
| on: | |
| push: | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| env: | |
| HARBOR_REGISTRY: docker-registry.ebrains.eu | |
| DOCKER_BUILDKIT: 1 | |
| DOCKER_CLIENT_TIMEOUT: 300 | |
| COMPOSE_HTTP_TIMEOUT: 300 | |
| RETRY_ATTEMPTS: "4" | |
| RETRY_SLEEP: "10" | |
| jobs: | |
| build_and_push_ui: | |
| name: Build PLATFORM-UI image and push to registries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Harbor connectivity probe | |
| run: | | |
| set -x | |
| getent hosts ${{ env.HARBOR_REGISTRY }} || true | |
| curl -vI --connect-timeout 10 https://${{ env.HARBOR_REGISTRY }}/v2/ || true | |
| - name: Disable IPv6 (job-scoped) | |
| run: | | |
| sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 | |
| sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Log in to EBRAINS HARBOR (retry) | |
| run: | | |
| for i in $(seq 1 ${{ env.RETRY_ATTEMPTS }}); do | |
| echo "${{ secrets.HARBOR_PASSWORD }}" | \ | |
| docker login ${{ env.HARBOR_REGISTRY }} \ | |
| -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin && exit 0 | |
| echo "Harbor login attempt $i failed; retrying in ${{ env.RETRY_SLEEP }}s..." | |
| sleep ${{ env.RETRY_SLEEP }} | |
| done | |
| echo "Harbor login failed after ${{ env.RETRY_ATTEMPTS }} attempts" >&2 | |
| exit 1 | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| hbpmip/platform-ui | |
| ${{ env.HARBOR_REGISTRY }}/medical-informatics-platform/platform-ui | |
| - name: Load PLATFORM-UI service cached image | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/.buildx-cache/platform-ui | |
| key: ${{ runner.os }}-buildx-platform-ui-${{ hashFiles('Dockerfile', 'nginx.conf.template', 'package.json', 'package-lock.json', 'angular.json', 'src/**', 'public/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-platform-ui- | |
| - name: Build PLATFORM-UI docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=local,src=/tmp/.buildx-cache/platform-ui | |
| cache-to: type=local,dest=/tmp/.buildx-cache-new/platform-ui | |
| - name: Move Docker images cache | |
| run: | | |
| rm -rf /tmp/.buildx-cache | |
| mv /tmp/.buildx-cache-new /tmp/.buildx-cache |