From 082d11309bc75cebe64e6056a1981a4f6359471b Mon Sep 17 00:00:00 2001 From: Jiri Travnicek Date: Sat, 23 Apr 2022 17:12:01 +0200 Subject: [PATCH 1/3] build arm64 --- .github/workflows/docker.yml | 85 +++++++++++++++++++++++++++++++++ .github/workflows/dockerhub.yml | 51 -------------------- 2 files changed, 85 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/dockerhub.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..408be1e --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,85 @@ +name: Build and release docker image + +on: + push: + tags: + - 'v*' + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Log in to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: | + krateng/maloja + ghcr.io/krateng/maloja + # generate Docker tags based on the following events/attributes + tags: | + type=semver,pattern={{version}} + flavor: | + latest=true + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: Containerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Update Readme and short description + uses: peter-evans/dockerhub-description@1cf9afbac3c5d2fdc66416a464c2c38260cb6f8d + continue-on-error: true + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + repository: krateng/maloja + short-description: ${{ github.event.repository.description }} diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml deleted file mode 100644 index f20b655..0000000 --- a/.github/workflows/dockerhub.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish to Dockerhub - -on: - push: - tags: - - 'v*' - -jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 - - - name: Log in to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@e5622373a38e60fb6d795a4421e56882f2d7a681 - with: - images: krateng/maloja - # generate Docker tags based on the following events/attributes - tags: | - type=semver,pattern={{version}} - flavor: | - latest=true - - - name: Build and push Docker image - uses: docker/build-push-action@7f9d37fa544684fb73bfe4835ed7214c255ce02b - with: - context: . - file: Containerfile - #platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - name: Update Readme and short description - uses: peter-evans/dockerhub-description@1cf9afbac3c5d2fdc66416a464c2c38260cb6f8d - continue-on-error: true - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - repository: krateng/maloja - short-description: ${{ github.event.repository.description }} From d54f2f8d35222844ec0bd8c382b92c6fad97a6bd Mon Sep 17 00:00:00 2001 From: Jiri Travnicek Date: Sat, 23 Apr 2022 20:38:18 +0200 Subject: [PATCH 2/3] ci: use specific commit tag for github actions --- .github/workflows/docker.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 408be1e..fc775b7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,18 +11,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out the repo - uses: actions/checkout@v2 + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - name: Log in to Docker Hub if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - name: Login to GHCR if: github.event_name != 'pull_request' - uses: docker/login-action@v1 + uses: docker/login-action@dd4fa0671be5250ee6f50aedf4cb05514abda2c7 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -30,7 +30,7 @@ jobs: - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v3 + uses: docker/metadata-action@f2a13332ac1ce8c0a71aeac48a150dbb1838ab67 with: images: | krateng/maloja @@ -42,13 +42,13 @@ jobs: latest=true - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@27d0a4f181a40b142cce983c5393082c365d1480 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@94ab11c41e45d028884a99163086648e898eed25 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@48af2dc4a9e8278b89d7fa154b955c30c6aaab09 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} @@ -56,7 +56,7 @@ jobs: ${{ runner.os }}-buildx- - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a with: context: . file: Containerfile @@ -76,7 +76,7 @@ jobs: mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: Update Readme and short description - uses: peter-evans/dockerhub-description@1cf9afbac3c5d2fdc66416a464c2c38260cb6f8d + uses: peter-evans/dockerhub-description@836d7e6aa8f6f32dce26f5a1dd46d3dc24997eae continue-on-error: true with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 9589a6a5c9f609a1a975778cf5da4dfe649ff8c8 Mon Sep 17 00:00:00 2001 From: Jiri Travnicek Date: Sat, 23 Apr 2022 20:39:42 +0200 Subject: [PATCH 3/3] use repository owner variable instead of hardcoding it --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fc775b7..f33c65e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,8 +33,8 @@ jobs: uses: docker/metadata-action@f2a13332ac1ce8c0a71aeac48a150dbb1838ab67 with: images: | - krateng/maloja - ghcr.io/krateng/maloja + ${{ github.repository_owner }}/maloja + ghcr.io/${{ github.repository_owner }}/maloja # generate Docker tags based on the following events/attributes tags: | type=semver,pattern={{version}}