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

chore: build arm64 docker images #110

Merged
merged 3 commits into from
Aug 1, 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
46 changes: 27 additions & 19 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,33 @@ on:
branches: [ "master" ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ghcr.io/havenweb/haven:$(echo $GITHUB_SHA | head -c7) --tag ghcr.io/havenweb/haven:latest

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image to GitHub
if: github.ref == 'refs/heads/master'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I first put together the container image build and push, I intended to build the image on every PR and every merge as part of CI, but only push the image on every merge to master--hence this condition. I don't see a similar condition in your code. Is it pushing to the github container registry on every run or only if we're merging to master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I forgot to include that part of the code. Let me fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah there is a small problem, you see the buildx action does everything in one go, so it builds and pushes. So I can't really tell it to push only on this condition.

run: |
docker push ghcr.io/havenweb/haven:$(echo $GITHUB_SHA | head -c7)
docker push ghcr.io/havenweb/haven:latest
- name: Checkout
uses: actions/checkout@v4

- name: Get tag
id: get_tag
run: echo "tagname=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

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

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

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/arm64
push: ${{ github.ref == 'refs/heads/master' }}
tags: ghcr.io/havenweb/haven:${{ steps.get_tag.outputs.tagname }}, ghcr.io/havenweb/haven:latest
Loading