Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use remote setup-docker action with arm64/v8 support #1122

Merged
merged 7 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions .github/workflows/_docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ on:
service-name:
required: true
type: string
docker-context-path:
required: false
type: string
dockerfile-path:
required: false
type: string
secrets:
ARM_RUNNER_HOSTNAME:
required: true
ARM_RUNNER_KEY:
required: true
outputs:
tag-value:
description: 'A semver compatible version retrieved from the tag'
Expand Down Expand Up @@ -46,33 +57,35 @@ jobs:
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.IMAGE_NAME }}:$t, ${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Setup repo
uses: blockscout/blockscout-ci-cd/.github/actions/setup-multiarch-buildx@master
id: setup
with:
docker-image: ${{ env.IMAGE_NAME }}
docker-username: ${{ github.actor }}
docker-password: ${{ secrets.GITHUB_TOKEN }}
docker-remote-multi-platform: true
docker-arm-host: ${{ secrets.ARM_RUNNER_HOSTNAME }}
docker-arm-host-key: ${{ secrets.ARM_RUNNER_KEY }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.service-name }}
file: '${{ inputs.service-name }}/Dockerfile'
context: ${{ inputs.docker-context-path || format('{0}/', inputs.service-name) }}
file: ${{ inputs.dockerfile-path || format('{0}/Dockerfile', inputs.service-name) }}
build-contexts: |
proto=proto
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
# platforms: |
# linux/amd64
# linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
linux/arm64/v8
labels: ${{ steps.setup.outputs.docker-labels }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}:build-cache,mode=max', env.IMAGE_NAME) || '' }}
59 changes: 8 additions & 51 deletions .github/workflows/bens.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,64 +122,21 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 60
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.regex.outputs.group2 }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/bens\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
uses: docker/build-push-action@v5
with:
context: "blockscout-ens"
file: "blockscout-ens/Dockerfile"
build-contexts: |
proto=proto
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: blockscout-ens
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
uses: './.github/workflows/npm-publisher.yml'
needs: push
if: needs.push.outputs.semver != ''
if: needs.push.outputs.tag-value != ''
secrets: inherit
with:
version: ${{ needs.push.outputs.semver }}
version: ${{ needs.push.outputs.tag-value }}
project_name: blockscout-ens

push-swagger:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/da-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: da-indexer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/eth-bytecode-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: eth-bytecode-db
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/multichain-aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: multichain-aggregator
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
52 changes: 8 additions & 44 deletions .github/workflows/multichain-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,47 +96,11 @@ jobs:
always() &&
(needs.test.result == 'success' || needs.test.result == 'cancelled') &&
(needs.lint.result == 'success' || needs.lint.result == 'cancelled')
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions-ecosystem/action-regex-match@v2
id: regex
with:
text: ${{ github.ref }}
regex: '^(refs\/tags\/multichain-search\/(v\d+\.\d+\.\d+))|(refs\/heads\/(main))$'

- name: Extract tag name
id: tags_extractor
run: |
t=${{ steps.regex.outputs.group2 }}
m=${{ steps.regex.outputs.group4 }}
(if ! [[ "$t" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$t, ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest; elif ! [[ "$m" == "" ]]; then echo tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$m; else echo tags=; fi) >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "multichain-search/backend"
file: "multichain-search/backend/Dockerfile"
push: ${{ steps.tags_extractor.outputs.tags != '' }}
tags: ${{ steps.tags_extractor.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:build-cache
cache-to: ${{ github.ref == 'refs/heads/main' && format('type=registry,ref={0}/{1}:build-cache,mode=max', env.REGISTRY, env.IMAGE_NAME) || '' }}
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: multichain-search
docker-context-path: "multichain-search/backend"
dockerfile-path: "multichain-search/backend/Dockerfile"
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}
3 changes: 3 additions & 0 deletions .github/workflows/proxy-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: proxy-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/sig-provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: sig-provider
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}


push-swagger:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/smart-contract-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: smart-contract-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/smart-guessr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: smart-guessr
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}
3 changes: 3 additions & 0 deletions .github/workflows/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: stats
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/stylus-verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: stylus-verifier
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}
3 changes: 3 additions & 0 deletions .github/workflows/user-ops-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: user-ops-indexer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

push-swagger:
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags'))
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/visualizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ jobs:
uses: ./.github/workflows/_docker-build-push.yml
with:
service-name: visualizer
secrets:
ARM_RUNNER_HOSTNAME: ${{ secrets.ARM_RUNNER_HOSTNAME }}
ARM_RUNNER_KEY: ${{ secrets.ARM_RUNNER_KEY }}

publish_types_package:
name: Publish types package
Expand Down
Loading