Skip to content

Commit

Permalink
Fix Github action to build & test amd64/arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Ledez committed Oct 6, 2023
1 parent 842babe commit f6fe5c6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/buildkitd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[worker.oci]
max-parallelism = 1
49 changes: 38 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkitd.toml
- name: Extract Kitsu & Zou versions
id: versions
run: |
Expand All @@ -42,7 +44,9 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Load Docker image

# amd64
- name: Load Docker amd64 image
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -51,23 +55,44 @@ jobs:
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Test docker image
- name: Test docker amd64 image
run: |
export CONTAINER_NAME=cgwire
export CONTAINER_NAME=cgwire-amd64
export LOCAL_PORT=8001
echo "KITSU_VERSION=${{ steps.versions.outputs.KITSU_VERSION }}" >> docker.env
echo "ZOU_VERSION=${{ steps.versions.outputs.ZOU_VERSION }}" >> docker.env
docker container run --platform=linux/amd64 -d --init -p 80:80 --rm --name ${CONTAINER_NAME} cgwire/cgwire:latest
echo "KITSU_URL=http://$(docker inspect ${CONTAINER_NAME} | jq -r '.[0]["NetworkSettings"]["IPAddress"]')" >> docker.env
docker container run --platform=linux/amd64 -d --init -p ${LOCAL_PORT}:80 --rm --name ${CONTAINER_NAME} cgwire/cgwire:latest
echo "KITSU_URL=http://$(docker inspect ${CONTAINER_NAME} | jq -r '.[0]["NetworkSettings"]["IPAddress"]'):${LOCAL_PORT}" >> docker.env
sleep 10
docker container run --env-file docker.env cgwire/kitsu-checker:latest
docker kill ${CONTAINER_NAME}
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
# arm64
- name: Load Docker arm64 image
uses: docker/build-push-action@v5
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
context: .
file: ./Dockerfile
platforms: linux/arm64
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Test docker arm64 image
run: |
export CONTAINER_NAME=cgwire-arm64
export LOCAL_PORT=8002
echo "KITSU_VERSION=${{ steps.versions.outputs.KITSU_VERSION }}" >> docker.env
echo "ZOU_VERSION=${{ steps.versions.outputs.ZOU_VERSION }}" >> docker.env
docker container run --platform=linux/arm64 -d --init -p ${LOCAL_PORT}:80 --rm --name ${CONTAINER_NAME} cgwire/cgwire:latest
echo "KITSU_URL=http://$(docker inspect ${CONTAINER_NAME} | jq -r '.[0]["NetworkSettings"]["IPAddress"]'):${LOCAL_PORT}" >> docker.env
sleep 30
docker container run --env-file docker.env cgwire/kitsu-checker:latest
docker kill ${CONTAINER_NAME}
- name: Push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v5
Expand All @@ -77,4 +102,6 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

0 comments on commit f6fe5c6

Please sign in to comment.