9.1.1 #4
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: | |
| release: | |
| types: [published] | |
| 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_backend: | |
| name: Build BACKEND 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@v4 | |
| 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-backend | |
| ${{ env.HARBOR_REGISTRY }}/medical-informatics-platform/platform-backend | |
| - name: Load BACKEND service cached image | |
| uses: actions/cache@v5 | |
| with: | |
| path: /tmp/.buildx-cache/backend | |
| key: ${{ runner.os }}-buildx-backend-${{ hashFiles('**/Dockerfile', '**/*.py', '**/*.js', '**/*.ts') }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-backend- | |
| - name: Build BACKEND 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/backend | |
| cache-to: type=local,dest=/tmp/.buildx-cache-new/backend | |
| - name: Move Docker images cache | |
| run: | | |
| rm -rf /tmp/.buildx-cache | |
| mv /tmp/.buildx-cache-new /tmp/.buildx-cache |