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

fix: use docker buildx on ci to support multiple arch #1912

Merged
merged 2 commits into from
Apr 11, 2024
Merged
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
99 changes: 50 additions & 49 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,70 @@ concurrency:
cancel-in-progress: true

jobs:
build-push:
build-main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build main Docker image
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker build -t ghcr.io/${owner}/${reponame} .
docker tag ghcr.io/${owner}/${reponame}:latest ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8}
- name: Get commit SHA
id: commit
run: echo "sha=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"

- name: Build slim Docker images
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker build --target=gnoland-slim -t ghcr.io/${owner}/${reponame}/gnoland-slim .
docker build --target=gnokey-slim -t ghcr.io/${owner}/${reponame}/gnokey-slim .
docker build --target=gno-slim -t ghcr.io/${owner}/${reponame}/gno-slim .
docker build --target=gnofaucet-slim -t ghcr.io/${owner}/${reponame}/gnofaucet-slim .
docker build --target=gnoweb-slim -t ghcr.io/${owner}/${reponame}/gnoweb-slim .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

docker tag ghcr.io/${owner}/${reponame}/gnoland-slim:latest ghcr.io/${owner}/${reponame}/gnoland-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnokey-slim:latest ghcr.io/${owner}/${reponame}/gnokey-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gno-slim:latest ghcr.io/${owner}/${reponame}/gno-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnofaucet-slim:latest ghcr.io/${owner}/${reponame}/gnofaucet-slim:${GITHUB_SHA::8}
docker tag ghcr.io/${owner}/${reponame}/gnoweb-slim:latest ghcr.io/${owner}/${reponame}/gnoweb-slim:${GITHUB_SHA::8}

- name: List docker images
run: |
docker images | grep ghcr

- name: Log in to GitHub Container Registry
if: (github.event_name != 'pull_request')
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: (github.event_name != 'pull_request')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ steps.commit.outputs.sha }}

- name: Publish images
if: (github.event_name != 'pull_request')
env:
owner: ${{ github.repository_owner }}
reponame: ${{ github.event.repository.name }}
run: |
docker push ghcr.io/${owner}/${reponame}:latest
docker push ghcr.io/${owner}/${reponame}:${GITHUB_SHA::8}

docker push ghcr.io/${owner}/${reponame}/gnoland-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnoland-slim:${GITHUB_SHA::8}
build-slim:
runs-on: ubuntu-latest
strategy:
matrix:
target: [gnoland, gnoland-slim, gnokey-slim, gno-slim, gnofaucet-slim, gnoweb-slim]
steps:
- name: Checkout
uses: actions/checkout@v4

docker push ghcr.io/${owner}/${reponame}/gnokey-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnokey-slim:${GITHUB_SHA::8}
- name: Get commit SHA
id: commit
run: echo "sha=${GITHUB_SHA::8}" >> "$GITHUB_OUTPUT"

docker push ghcr.io/${owner}/${reponame}/gno-slim:latest
docker push ghcr.io/${owner}/${reponame}/gno-slim:${GITHUB_SHA::8}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

docker push ghcr.io/${owner}/${reponame}/gnofaucet-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnofaucet-slim:${GITHUB_SHA::8}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

docker push ghcr.io/${owner}/${reponame}/gnoweb-slim:latest
docker push ghcr.io/${owner}/${reponame}/gnoweb-slim:${GITHUB_SHA::8}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: (github.event_name != 'pull_request')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.target }}:latest
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.target }}:${{ steps.commit.outputs.sha }}
Loading