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

feat(ci): update Docker workflows for multi-architecture builds #10

Merged
merged 6 commits into from
Feb 5, 2025
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
82 changes: 65 additions & 17 deletions .github/workflows/kiterunner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ env:
KR_DIR: "/usr/local/kiterunner"

jobs:
build-and-push:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

build-and-push-amd64:
runs-on: ubuntu-latest # Native amd64 GitHub runner
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master
Expand All @@ -35,28 +31,80 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: ${{ github.workspace }}/.build-cache
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-build-

- name: Build and push Docker image
run: |
docker buildx build --push \
docker build --platform linux/amd64 \
--build-arg "KR_DIR=${{ env.KR_DIR }}" --build-arg "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest \
--platform linux/amd64,linux/arm64 ./files/kiterunner
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64 \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64 ./files/kiterunner
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64

- name: Logout from Docker Hub
run: docker logout

build-and-push-arm64:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master

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

- name: Build and push arm64 Docker image
run: |
docker build --platform linux/arm64 \
--build-arg "KR_DIR=${{ env.KR_DIR }}" --build-arg "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64 \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64 ./files/kiterunner
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64

- name: Logout from Docker Hub
run: docker logout

create-multiarch-manifest:
needs: [build-and-push-amd64, build-and-push-arm64]
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-platform manifest
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64

docker manifest create ghcr.io/${{ github.repository_owner }}/kiterunner:latest \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64

docker manifest push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}
docker manifest push ghcr.io/${{ github.repository_owner }}/kiterunner:latest

security-scan:
needs: create-multiarch-manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} image
uses: snyk/actions/docker@master
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/metasploit-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
repository: rapid7/metasploit-framework
path: metasploit-framework
ref: ${{ env.RELEASE_VERSION }}

- name: Check ghcr.io/${{ github.repository_owner }}/metasploit-framework:${{ env.RELEASE_VERSION }} image
uses: snyk/actions/docker@master
continue-on-error: true
Expand Down
Loading