Skip to content

Commit

Permalink
fix(build): docker build manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
revitteth committed Apr 8, 2024
1 parent 2783a46 commit d81c322
Showing 1 changed file with 33 additions and 34 deletions.
67 changes: 33 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare
id: prep
run: |
Expand All @@ -45,69 +44,69 @@ jobs:
fi
fi
echo "version=$TAG" >> $GITHUB_OUTPUT
# Determine if latest tag should be applied
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "LATEST_TAG=false" >> $GITHUB_ENV
else
echo "LATEST_TAG=true" >> $GITHUB_ENV
fi
build-and-push-amd64:
build-amd64:
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

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

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

uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: Build and Push Docker Image (amd64)
uses: docker/build-push-action@v5
- name: Build and push AMD64 image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.version }}
${{ needs.prepare.outputs.latest_tag == 'true' && format('{0}:latest', env.IMAGE_NAME) || '' }}
tags: ${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.version }}-amd64
platforms: linux/amd64

build-and-push-arm64:
build-arm64:
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

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

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

uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}

- name: Build and Push Docker Image (arm64)
uses: docker/build-push-action@v5
- name: Build and push ARM64 image
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/arm64
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.version }}
${{ needs.prepare.outputs.latest_tag == 'true' && format('{0}:latest', env.IMAGE_NAME) || '' }}
tags: ${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.version }}-arm64
platforms: linux/arm64

create-and-push-manifest:
needs: [build-amd64, build-arm64]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ env.DOCKERHUB_TOKEN }}
- name: Create and push manifest
run: |
docker buildx create --use
docker buildx build --push --platform linux/amd64,linux/arm64 --tag ${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.version }} --file Dockerfile .
if [ "${{ needs.prepare.outputs.latest_tag }}" == "true" ]; then
docker buildx build --push --platform linux/amd64,linux/arm64 --tag ${{ env.IMAGE_NAME }}:latest --file Dockerfile .
fi

0 comments on commit d81c322

Please sign in to comment.