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(build): docker build manifest #267

Merged
merged 2 commits into from
Apr 8, 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
65 changes: 35 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Build and Push Docker

on:
push:
branches:
- fix/docker-build-push
tags:
- 'v*'
release:
Expand All @@ -26,7 +28,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare
id: prep
run: |
Expand All @@ -45,69 +46,73 @@ 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

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

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
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@v3
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

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

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v3
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@v3
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: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
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
Loading