From 21a14fc1843539e22fa6c4162b75e54b3b7aba39 Mon Sep 17 00:00:00 2001 From: Arturomtz8 Date: Sat, 2 Nov 2024 18:15:31 -0600 Subject: [PATCH 1/2] add different platforms for docker img --- .github/workflows/release.yaml | 2 +- tools/docker.sh | 38 ++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 613184ab..79336f03 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -23,4 +23,4 @@ jobs: with: fetch-depth: 0 - run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - - run: tools/docker.sh + - run: tools/docker.sh "linux/amd64,linux/arm64" diff --git a/tools/docker.sh b/tools/docker.sh index 7af645c8..2e76888c 100755 --- a/tools/docker.sh +++ b/tools/docker.sh @@ -2,7 +2,37 @@ set -e -for tag in latest $(git tag --points-at | sed s/^v//); do - docker build -t raviqqe/muffet:$tag . - docker push raviqqe/muffet:$tag -done +check_buildx(){ + if docker buildx version &>/dev/null; then + return 0 + fi + if docker buildx ls &>/dev/null; then + return 0 + fi + return 1 +} + +build_multiarch() { + if ! check_buildx; then + echo "Error: Docker buildx is not installed or not working" + return 1 + fi + + local platforms=${1:-"linux/amd64"} + + docker buildx create --name multiarch --use || true + + echo "Building for platforms: $platforms" + + # Build for each git tag and latest + for tag in latest $(git tag --points-at | sed s/^v//); do + docker buildx build \ + --platform "$platforms" \ + --tag raviqqe/muffet:$tag \ + --push \ + . + done +} + + +build_multiarch "$@" \ No newline at end of file From 9419f0a1aef470fc9adf03e554e0ee48c2b237ee Mon Sep 17 00:00:00 2001 From: Arturomtz8 Date: Sat, 2 Nov 2024 20:29:42 -0600 Subject: [PATCH 2/2] minor changes, suggestions from danvergara --- tools/docker.sh | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/tools/docker.sh b/tools/docker.sh index 2e76888c..6e9c1810 100755 --- a/tools/docker.sh +++ b/tools/docker.sh @@ -3,36 +3,29 @@ set -e check_buildx(){ - if docker buildx version &>/dev/null; then - return 0 - fi - if docker buildx ls &>/dev/null; then - return 0 - fi - return 1 + docker buildx version &>/dev/null + return $? } -build_multiarch() { - if ! check_buildx; then - echo "Error: Docker buildx is not installed or not working" - return 1 +build_image() { + local platforms=${1:-} + if [ ! -z "$platforms" ] && check_buildx; then + echo "Building for platforms: $platforms" + # Build for each git tag and latest + for tag in latest $(git tag --points-at | sed s/^v//); do + docker buildx build \ + --platform "$platforms" \ + --tag raviqqe/muffet:$tag \ + --push \ + . + done + else + for tag in latest $(git tag --points-at | sed s/^v//); do + docker build -t raviqqe/muffet:$tag . + docker push raviqqe/muffet:$tag + done fi - - local platforms=${1:-"linux/amd64"} - - docker buildx create --name multiarch --use || true - - echo "Building for platforms: $platforms" - - # Build for each git tag and latest - for tag in latest $(git tag --points-at | sed s/^v//); do - docker buildx build \ - --platform "$platforms" \ - --tag raviqqe/muffet:$tag \ - --push \ - . - done } -build_multiarch "$@" \ No newline at end of file +build_image "$@" \ No newline at end of file