From 11cad929007d1113db7f09978f39d13f18a6ca0b Mon Sep 17 00:00:00 2001 From: Vitor Lima Date: Wed, 19 Jun 2024 22:40:56 -0300 Subject: [PATCH] chore: Testing a faster dockhub build method --- .github/workflows/build-dockerhub.yml | 6 +++++- dockerhub.sh | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-dockerhub.yml b/.github/workflows/build-dockerhub.yml index a9b918d..0c699c2 100644 --- a/.github/workflows/build-dockerhub.yml +++ b/.github/workflows/build-dockerhub.yml @@ -12,6 +12,9 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + architecture: [arm64, amd64] environment: PROD steps: @@ -38,9 +41,10 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + # linux/arm64/v8,linux/amd64 - name: Build and deploy images env: CARGO_SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }} CARGO_SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }} CARGO_SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }} - run: bash dockerhub.sh ${{ github.event.inputs.version }} + run: bash dockerhub.sh linux/${{ matrix.architecture }} ${{ github.event.inputs.version || github.event.release.tag_name }} diff --git a/dockerhub.sh b/dockerhub.sh index b61e724..1e195b8 100644 --- a/dockerhub.sh +++ b/dockerhub.sh @@ -1,11 +1,22 @@ #!/bin/bash -# Ensure a version is provided +# Ensure a platform is provided if [ -z "$1" ]; then + echo "Error: No platform provided." + exit 1 +fi + +# Ensure a version is provided +if [ -z "$2" ]; then echo "Error: No version provided." exit 1 fi -FULL_VERSION=$1 +PLATFORM=$1 +if [ "$PLATFORM" == "linux/arm64" ]; then + PLATFORM="linux/arm64/v8" +fi + +FULL_VERSION=$2 SPLIT=(${FULL_VERSION//./ }) MAJOR=${SPLIT[0]} @@ -43,7 +54,7 @@ docker buildx build --push --build-arg TAGORELAY_VERSION=${FULL_VERSION} \ --build-arg CARGO_SERVER_SSL_CA=${CARGO_SERVER_SSL_CA_BASE64} \ --build-arg CARGO_SERVER_SSL_CERT=${CARGO_SERVER_SSL_CERT_BASE64} \ --build-arg CARGO_SERVER_SSL_KEY=${CARGO_SERVER_SSL_KEY_BASE64} \ - --platform linux/arm64/v8,linux/amd64 \ + --platform ${PLATFORM} \ --tag tagoio/relay \ --tag tagoio/relay:debian \ --tag tagoio/relay:bookworm \