Skip to content

Commit

Permalink
Merge pull request #4 from manics/multi-arch-image
Browse files Browse the repository at this point in the history
Build multi-arch image
  • Loading branch information
manics committed Nov 10, 2023
2 parents 10976ba + d48d50f commit c394adf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
62 changes: 36 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,27 @@ jobs:
contents: read
packages: write
env:
REGISTRY: ghcr.io
DEFAULT_REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

services:
# So that we can test this in PRs/branches
local-registry:
image: registry:2
ports:
- 5000:5000

steps:
- name: Should we push this image to a public registry?
run: |
if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then
REGISTRY=$DEFAULT_REGISTRY
else
REGISTRY=localhost:5000
fi
echo "REGISTRY=$REGISTRY" >> $GITHUB_ENV
echo "Publishing to $REGISTRY"
- name: Checkout code
uses: actions/checkout@v4
with:
Expand All @@ -118,32 +136,24 @@ jobs:
run: |
echo "SHORT_REF=${GITHUB_REF##refs*/}" >> $GITHUB_ENV
# https://www.redhat.com/en/blog/build-ubi-containers-github-actions-buildah-and-podman
- name: Buildah Action
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: ${{ env.SHORT_REF }}
containerfiles: |
./Dockerfile
- name: Log in to the GitHub Container registry
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')
uses: redhat-actions/podman-login@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU to build multiple platforms
uses: docker/setup-qemu-action@v3

- name: Push to GitHub Container Repository
if: startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main')
uses: redhat-actions/push-to-registry@v2
- name: Set up Docker Buildx (for multi-arch builds)
uses: docker/setup-buildx-action@v3
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ${{ env.REGISTRY }}
# Allows pushing to registry on localhost:5000
driver-opts: network=host

- name: Run repo2docker image
- name: Login to registry
if: env.REGISTRY != 'localhost:5000'
run: |
podman run ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHORT_REF }} repo2docker --version
docker login -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" "${{ env.REGISTRY }}"
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.SHORT_REF }}
3 changes: 3 additions & 0 deletions ci/build-and-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ echo "::endgroup::"
echo "::group::Check repo2kaniko"
echo password | $ENGINE login --username=user --password-stdin --tls-verify=false localhost:5000
$ENGINE pull localhost:5000/test-conda:ci
echo "repo2docker --version:"
$ENGINE run $REPO2KANIKO_IMAGE repo2docker --version
echo "/home/jovyan/verify:"
$ENGINE run --rm localhost:5000/test-conda:ci /home/jovyan/verify

./ci/check-registry.py
Expand Down

0 comments on commit c394adf

Please sign in to comment.