Skip to content

Commit

Permalink
ci(github): use ARM runner
Browse files Browse the repository at this point in the history
  • Loading branch information
donch1989 committed Feb 4, 2025
1 parent 4425c45 commit 4fc3c57
Showing 1 changed file with 103 additions and 18 deletions.
121 changes: 103 additions & 18 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,73 @@
name: Build and Push Images

on:
push:
workflow_call:
release:
types: [published]

jobs:
docker-hub:
runs-on: ubuntu-latest
build-amd64:
runs-on: ubuntu-24.04
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
- uses: actions/checkout@v3
with:
overprovision-lvm: "true"
remove-dotnet: "true"
build-mount-path: "/var/lib/docker/"
token: ${{ secrets.botGitHubToken }}

- name: Restart docker
run: sudo service docker restart
- name: Load .env file
uses: cardinalby/export-env-action@v2
with:
envFile: .env

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: dropletbot
password: ${{ secrets.botDockerHubPassword }}

- name: Build and push amd64 (latest)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
context: .
push: true
build-args: |
SERVICE_NAME=pipeline-backend
tags: instill/pipeline-backend:${{ github.sha }}-amd64
cache-from: type=registry,ref=instill/pipeline-backend:buildcache
cache-to: type=registry,ref=instill/pipeline-backend:buildcache,mode=max

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Versions
if: github.event_name == 'release'
uses: actions/github-script@v6
id: set_version
with:
platforms: arm64
script: |
const tag = '${{ github.ref_name }}'
const no_v_tag = tag.replace('v', '')
core.setOutput('tag', tag)
core.setOutput('no_v_tag', no_v_tag)
- name: Build and push amd64 (release)
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
platforms: linux/amd64
context: .
push: true
build-args: |
SERVICE_NAME=pipeline-backend
tags: instill/pipeline-backend:${{ github.sha }}-amd64
cache-from: type=registry,ref=instill/pipeline-backend:buildcache
cache-to: type=registry,ref=instill/pipeline-backend:buildcache,mode=max

build-arm64:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.botGitHubToken }}
Expand All @@ -42,16 +86,16 @@ jobs:
username: dropletbot
password: ${{ secrets.botDockerHubPassword }}

- name: Build and push (latest)
- name: Build and push arm64 (latest)
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
platforms: linux/arm64
context: .
push: true
build-args: |
SERVICE_NAME=pipeline-backend
tags: instill/pipeline-backend:latest
tags: instill/pipeline-backend:${{ github.sha }}-arm64
cache-from: type=registry,ref=instill/pipeline-backend:buildcache
cache-to: type=registry,ref=instill/pipeline-backend:buildcache,mode=max

Expand All @@ -66,15 +110,56 @@ jobs:
core.setOutput('tag', tag)
core.setOutput('no_v_tag', no_v_tag)
- name: Build and push (release)
- name: Build and push arm64 (release)
if: github.event_name == 'release'
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
platforms: linux/arm64
context: .
push: true
build-args: |
SERVICE_NAME=pipeline-backend
tags: instill/pipeline-backend:${{steps.set_version.outputs.no_v_tag}}
tags: instill/pipeline-backend:${{ github.sha }}-arm64
cache-from: type=registry,ref=instill/pipeline-backend:buildcache
cache-to: type=registry,ref=instill/pipeline-backend:buildcache,mode=max

merge-manifests:
needs: [build-amd64, build-arm64]
runs-on: ubuntu-24.04
steps:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: dropletbot
password: ${{ secrets.botDockerHubPassword }}

- name: Create and push multi-arch manifest (latest)
if: github.ref == 'refs/heads/main'
run: |
docker manifest create instill/pipeline-backend:latest \
instill/pipeline-backend:${{ github.sha }}-amd64 \
instill/pipeline-backend:${{ github.sha }}-arm64
docker manifest push instill/pipeline-backend:latest
docker manifest rm instill/pipeline-backend:${{ github.sha }}-amd64
docker manifest rm instill/pipeline-backend:${{ github.sha }}-arm64
- name: Set Versions
if: github.event_name == 'release'
uses: actions/github-script@v6
id: set_version
with:
script: |
const tag = '${{ github.ref_name }}'
const no_v_tag = tag.replace('v', '')
core.setOutput('tag', tag)
core.setOutput('no_v_tag', no_v_tag)
- name: Create and push multi-arch manifest (release)
if: github.event_name == 'release'
run: |
docker manifest create instill/pipeline-backend:${{steps.set_version.outputs.no_v_tag}} \
instill/pipeline-backend:${{ github.sha }}-amd64 \
instill/pipeline-backend:${{ github.sha }}-arm64
docker manifest push instill/pipeline-backend:${{steps.set_version.outputs.no_v_tag}}
docker manifest rm instill/pipeline-backend:${{ github.sha }}-amd64
docker manifest rm instill/pipeline-backend:${{ github.sha }}-arm64

0 comments on commit 4fc3c57

Please sign in to comment.