From 2928ef76dac3ced671d6a4a9a0d05f42a98a0cbd Mon Sep 17 00:00:00 2001 From: Nico Singh Date: Fri, 14 Jan 2022 15:34:44 -0300 Subject: [PATCH] set up buildx remove comments check available platforms use QEMU to check if there are more available platforms build in all platforms set ARM and AMD archs only check available docker options use docker buildx command fix command set parallel builds to 1 use build action set multiple tags set image name as CI variable push image to dockerhub unlock other platforms remove unused files and set correct docker image name put supported platforms as variable use action version fix action version --- .github/buildkitd.toml | 2 ++ .github/workflows/deploy.yml | 27 +++++++++++++++++++++------ scripts/build-push.sh | 15 --------------- scripts/build.sh | 6 ------ scripts/docker-login.sh | 5 ----- 5 files changed, 23 insertions(+), 32 deletions(-) create mode 100644 .github/buildkitd.toml delete mode 100644 scripts/build-push.sh delete mode 100644 scripts/build.sh delete mode 100644 scripts/docker-login.sh diff --git a/.github/buildkitd.toml b/.github/buildkitd.toml new file mode 100644 index 0000000..f6dc454 --- /dev/null +++ b/.github/buildkitd.toml @@ -0,0 +1,2 @@ +[worker.oci] + max-parallelism = 1 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8f0036c..9e33146 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -5,14 +5,29 @@ on: branches: - master +env: + image_name: tiangolo/nginx-rtmp + supported_platforms: "linux/amd64,linux/arm64,linux/386,linux/arm/v7,linux/arm/v6" + jobs: build: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - - name: Deploy Image - run: bash scripts/build-push.sh - env: - NAME: latest - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - uses: srfrnk/current-time@v1.1.0 + id: current-time + with: + format: YYYY-MM-DD + - uses: docker/setup-qemu-action@v1 + - uses: docker/setup-buildx-action@v1 + with: + config: .github/buildkitd.toml + - uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - uses: docker/build-push-action@v2 + with: + platforms: ${{ env.supported_platforms }} + tags: "${{ env.image_name }}:latest-${{ steps.current-time.outputs.formattedTime }},${{ env.image_name }}:latest" + push: true diff --git a/scripts/build-push.sh b/scripts/build-push.sh deleted file mode 100644 index 6653cdb..0000000 --- a/scripts/build-push.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -e - -use_tag="tiangolo/nginx-rtmp:$NAME" -use_dated_tag="${use_tag}-$(date -I)" - -bash scripts/build.sh - -docker tag "$use_tag" "$use_dated_tag" - -bash scripts/docker-login.sh - -docker push "$use_tag" -docker push "$use_dated_tag" diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index 1ee0a9b..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -e - -use_tag="tiangolo/nginx-rtmp:$NAME" - -docker build -t "$use_tag" . diff --git a/scripts/docker-login.sh b/scripts/docker-login.sh deleted file mode 100644 index d872c89..0000000 --- a/scripts/docker-login.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin