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

feat: publish multi arch docker image to dockerhub #751

Merged
merged 43 commits into from
Jun 10, 2024
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
fa4dc16
chore: Update Docker workflow to use Buildpacks
Ch4s3r May 31, 2024
6432b4a
chore: add workflow dispatch
Ch4s3r May 31, 2024
b88d090
chore: docker login
Ch4s3r May 31, 2024
b65c0a0
chore: add multi arch builds
Ch4s3r May 31, 2024
2fea88d
fix linebreaks
Ch4s3r May 31, 2024
3977607
print pack version
Ch4s3r May 31, 2024
3928ca4
update pack action
Ch4s3r May 31, 2024
3734f80
chore: Update Docker workflow to use Buildpacks
Ch4s3r May 31, 2024
cfbc187
curl
Ch4s3r May 31, 2024
b8787ac
use linux version of pack
Ch4s3r May 31, 2024
9aedd77
fix platform
Ch4s3r May 31, 2024
a191b54
fix platform
Ch4s3r May 31, 2024
03a735d
use only arm
Ch4s3r May 31, 2024
68c5d0c
no platform
Ch4s3r May 31, 2024
8155073
try amd
Ch4s3r May 31, 2024
07aa71a
remove buildpackless
Ch4s3r May 31, 2024
f3a993a
chore: Update Docker workflow to use Buildpacks with multiple platforms
Ch4s3r May 31, 2024
bfbd8a1
chore: Update Docker workflow to use Buildpacks with multiple platforms
Ch4s3r May 31, 2024
8650357
chore: Update Docker workflow to use Buildpacks with multiple platforms
Ch4s3r May 31, 2024
a4c8dbb
Update docker.yml
Ch4s3r Jun 7, 2024
5001ae8
Update docker.yml
Ch4s3r Jun 7, 2024
850db9b
Update docker.yml
Ch4s3r Jun 7, 2024
3532a80
Update docker.yml
Ch4s3r Jun 7, 2024
f47326a
Update docker.yml
Ch4s3r Jun 7, 2024
85f832d
Update docker.yml
Ch4s3r Jun 7, 2024
74182d9
Update docker.yml
Ch4s3r Jun 7, 2024
3abfa15
Update docker.yml
Ch4s3r Jun 7, 2024
7a98a37
Update docker.yml
Ch4s3r Jun 7, 2024
1e617ce
Update docker.yml
Ch4s3r Jun 7, 2024
1d2a7de
Update docker.yml
Ch4s3r Jun 7, 2024
54ba9c6
Update docker.yml
Ch4s3r Jun 7, 2024
c8d1b24
Update docker.yml
Ch4s3r Jun 7, 2024
0306422
Update docker.yml
Ch4s3r Jun 7, 2024
33e0498
Update docker.yml
Ch4s3r Jun 7, 2024
9bf03e6
Create buildpack
Ch4s3r Jun 7, 2024
cb422f3
Rename buildpack to buildpack.yaml
Ch4s3r Jun 7, 2024
fa25e70
Update buildpack.yaml
Ch4s3r Jun 7, 2024
c85539a
Update docker.yml
Ch4s3r Jun 7, 2024
acc96ba
Delete .github/workflows/buildpack.yaml
Ch4s3r Jun 7, 2024
9accbe7
Update docker.yml
Ch4s3r Jun 7, 2024
54a26fd
Update docker.yml
Ch4s3r Jun 7, 2024
a80eaa9
Update docker.yml
Ch4s3r Jun 7, 2024
4bf215e
Update docker.yml
Ch4s3r Jun 7, 2024
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
145 changes: 96 additions & 49 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,113 @@
name: Docker Release
name: Docker

on:
push:
tags:
- '*'
branches:
- master
- "*"
workflow_dispatch:

permissions:
contents: read
env:
REGISTRY_IMAGE: mergeability/mergeable

jobs:
init:
permissions:
contents: none
runs-on: ubuntu-latest
outputs:
do_docker: ${{ steps.vars.outputs.IS_DOCKERHUB_PUSH }}
steps:
- name: Initialize workflow variables
shell: bash
run: |
# work-around for inaccessible 'secrets' object for 'if'; see <https://github.community/t5/GitHub-Actions/jobs-lt-job-id-gt-if-does-not-work-with-env-secrets/m-p/38549>)
unset IS_DOCKERHUB_PUSH
if [ -z "$DOCKERHUB_PUSH" ]; then IS_DOCKERHUB_PUSH='false'; else IS_DOCKERHUB_PUSH='true' ; fi
echo set-output name=IS_DOCKERHUB_PUSH::${IS_DOCKERHUB_PUSH}
echo ::set-output name=IS_DOCKERHUB_PUSH::${IS_DOCKERHUB_PUSH}
env:
DOCKERHUB_PUSH: ${{ secrets.DOCKERHUB_PUSH }}
build:
name: Build and push Docker image
runs-on: ubuntu-latest
needs: [init]
if: ${{ needs.init.outputs.do_docker == 'true' }}
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
# Failing to build
# - linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

- name: Checkout
uses: actions/checkout@v2

uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

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

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push latest
uses: docker/build-push-action@v2
if: github.ref == 'refs/heads/master'
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}:latest

- name: Set version variable
id: version
if: startsWith(github.ref, 'refs/tags/')
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=build-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }}

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"

- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Build and push tag
uses: docker/build-push-action@v2
if: startsWith(github.ref, 'refs/tags/')
merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}:${{ steps.version.outputs.TAG }}
images: ${{ env.REGISTRY_IMAGE }}
tags: |
# minimal
type=semver,pattern={{version}}
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}