From 9f2befd051acc71dfd3b24920a6366242e666c0b Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 29 Aug 2024 10:35:02 +0200 Subject: [PATCH 01/13] feat: Add support for ARM servers --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 705269a53..6ad1ff22a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,6 +50,10 @@ jobs: password: ${{ secrets.DOCKER_TOKEN }} if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -57,6 +61,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . + platforms: linux/amd64,linux/arm64 push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} file: ./Dockerfile tags: ${{ steps.meta.outputs.tags }} From 588f549448e88b782378763771ffc66e3a4631c6 Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 29 Aug 2024 14:08:45 +0200 Subject: [PATCH 02/13] fix: lint issues in Dockerfile --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 10ec65d90..78ea17dd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/oven/bun:1-alpine as BUILD_IMAGE +FROM docker.io/oven/bun:1-alpine AS build-image # go to work folder WORKDIR /usr/src/app @@ -28,7 +28,7 @@ rm -rf node_modules && \ bun install --frozen-install --production # go to another VM -FROM docker.io/oven/bun:1-alpine as PROD_IMAGE +FROM docker.io/oven/bun:1-alpine AS prod-image # inform software to be in production ENV NODE_ENV=production @@ -40,11 +40,11 @@ USER bun WORKDIR /usr/src/app # copy from build image -COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/generated ./generated -COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/node_modules ./node_modules -COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/src ./src -COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/public ./public -COPY --chown=bun:bun --from=BUILD_IMAGE /usr/src/app/server/package.json ./package.json +COPY --chown=bun:bun --from=build-image /usr/src/app/server/generated ./generated +COPY --chown=bun:bun --from=build-image /usr/src/app/server/node_modules ./node_modules +COPY --chown=bun:bun --from=build-image /usr/src/app/server/src ./src +COPY --chown=bun:bun --from=build-image /usr/src/app/server/public ./public +COPY --chown=bun:bun --from=build-image /usr/src/app/server/package.json ./package.json # Expose port EXPOSE 3000 From 69fed9ea3de8b4876e598c874870a057326639e2 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 10:25:16 +0200 Subject: [PATCH 03/13] Update build.yml --- .github/workflows/build.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ad1ff22a..f7bc19ca5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,6 @@ jobs: password: ${{ secrets.DOCKER_TOKEN }} if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -61,7 +57,7 @@ jobs: uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} file: ./Dockerfile tags: ${{ steps.meta.outputs.tags }} From a04b9c70a9899350a478ea57e0861fcec8320cd0 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 10:26:11 +0200 Subject: [PATCH 04/13] Create build_arm.yml --- .github/workflows/build_arm.yml | 68 +++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/build_arm.yml diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml new file mode 100644 index 000000000..c3998ca28 --- /dev/null +++ b/.github/workflows/build_arm.yml @@ -0,0 +1,68 @@ +name: Build ARM Docker image +on: + push: + branches: + - '*' + tags: + - v* + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/tcgdex/server + tcgdex/server + tags: | + type=edge + type=ref,event=pr + type=ref,event=branch,prefix=branch- + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=semver,pattern=latest + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + - name: Login to Github Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + file: ./Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 5cb5dc8e445248b3f3e9a37d2f804788a449429b Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 10:51:37 +0200 Subject: [PATCH 05/13] feat: add caching to build --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++- .github/workflows/build_arm.yml | 68 --------------------------------- 2 files changed, 61 insertions(+), 69 deletions(-) delete mode 100644 .github/workflows/build_arm.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7bc19ca5..57f24dce6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ on: - master jobs: - build: + build_amd: runs-on: ubuntu-latest steps: @@ -62,3 +62,63 @@ jobs: file: ./Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build_arm: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/tcgdex/server + tcgdex/server + tags: | + type=edge + type=ref,event=pr + type=ref,event=branch,prefix=branch- + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=semver,pattern=latest + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + - name: Login to Github Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/arm64 + push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + file: ./Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml deleted file mode 100644 index c3998ca28..000000000 --- a/.github/workflows/build_arm.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Build ARM Docker image -on: - push: - branches: - - '*' - tags: - - v* - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/tcgdex/server - tcgdex/server - tags: | - type=edge - type=ref,event=pr - type=ref,event=branch,prefix=branch- - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=semver,pattern=latest - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Login to Github Packages - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - file: ./Dockerfile - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} From c76d63a58c0f6ff23de477a63d078762e79de2d7 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 12:18:19 +0200 Subject: [PATCH 06/13] Update build.yml --- .github/workflows/build.yml | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 57f24dce6..4876a033c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,9 @@ on: jobs: build_amd: runs-on: ubuntu-latest + outputs: + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} steps: - name: Checkout @@ -53,7 +56,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push + - name: Build and push AMD64 image uses: docker/build-push-action@v6 with: context: . @@ -64,8 +67,11 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build_arm: runs-on: ubuntu-latest + needs: build_amd # Ensures ARM64 build waits for AMD64 to finish + # if: github.event_name != 'pull_request' # Optional: Skip ARM64 build on PRs for faster feedback steps: - name: Checkout @@ -80,14 +86,8 @@ jobs: images: | ghcr.io/tcgdex/server tcgdex/server - tags: | - type=edge - type=ref,event=pr - type=ref,event=branch,prefix=branch- - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=semver,pattern=latest + tags: ${{ needs.build_amd.outputs.tags }} + labels: ${{ needs.build_amd.outputs.labels }} - name: Login to Docker Hub uses: docker/login-action@v3 @@ -104,21 +104,22 @@ jobs: password: ${{ secrets.DOCKER_TOKEN }} if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Set up QEMU + - name: Set up QEMU for ARM emulation uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + install: true - - name: Build and push + - name: Build and push ARM64 image uses: docker/build-push-action@v6 with: context: . platforms: linux/arm64 push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} file: ./Dockerfile - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ needs.build_amd.outputs.tags }} + labels: ${{ needs.build_amd.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max From 930b18e80aa5f9a1c6ee3ebadf970e0ff4bbc845 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 14:14:32 +0200 Subject: [PATCH 07/13] Update build.yml --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4876a033c..f504886dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -119,7 +119,7 @@ jobs: platforms: linux/arm64 push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} file: ./Dockerfile - tags: ${{ needs.build_amd.outputs.tags }} - labels: ${{ needs.build_amd.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max From 0ede67bd7d83b1f9f7ad6224ef54d3dad5a9b619 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 14:42:49 +0200 Subject: [PATCH 08/13] Update build.yml --- .github/workflows/build.yml | 257 ++++++++++++++++++++---------------- 1 file changed, 140 insertions(+), 117 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f504886dd..afe1c2e34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,125 +1,148 @@ -name: Build Docker image +name: ci + on: push: - branches: - - '*' - tags: - - v* - pull_request: - branches: - - master + +env: + REGISTRY_IMAGE: | + ghcr.io/tcgdex/server + tcgdex/server jobs: - build_amd: + build: runs-on: ubuntu-latest - outputs: - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + # - linux/arm/v6 + # - linux/arm/v7 + - linux/arm64 steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/tcgdex/server - tcgdex/server - tags: | - type=edge - type=ref,event=pr - type=ref,event=branch,prefix=branch- - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=semver,pattern=latest - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Login to Github Packages - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push AMD64 image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/amd64 - push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - file: ./Dockerfile - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - build_arm: - runs-on: ubuntu-latest - needs: build_amd # Ensures ARM64 build waits for AMD64 to finish - # if: github.event_name != 'pull_request' # Optional: Skip ARM64 build on PRs for faster feedback + - name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=edge + type=ref,event=pr + type=ref,event=branch,prefix=branch- + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=semver,pattern=latest + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + - name: Login to Github Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + if: ${{ matrix.platform != 'linux/amd64' }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.platform }} + file: ./Dockerfile + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: | + ${{ env.REGISTRY_IMAGES }} | while read image; do + echo "type=image,name=$image,push-by-digest=true,name-canonical=true,push=true"; + done + + - 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 + + deploy: + runs-on: ubuntu-latest + if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} + needs: + - build steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/tcgdex/server - tcgdex/server - tags: ${{ needs.build_amd.outputs.tags }} - labels: ${{ needs.build_amd.outputs.labels }} - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Login to Github Packages - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_TOKEN }} - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - - - name: Set up QEMU for ARM emulation - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - install: true - - - name: Build and push ARM64 image - uses: docker/build-push-action@v6 - with: - context: . - platforms: linux/arm64 - push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - file: ./Dockerfile - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + - 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: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=edge + type=ref,event=pr + type=ref,event=branch,prefix=branch- + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=semver,pattern=latest + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Login to Github Packages + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Create manifest list and push for each image + working-directory: /tmp/digests + run: | + echo "${{ env.REGISTRY_IMAGES }}" | while read image; do + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf "$image@sha256:%s " *); + done + + - name: Inspect image + run: | + echo "${{ env.REGISTRY_IMAGES }}" | while read image; do + docker buildx imagetools inspect $image:${{ steps.meta.outputs.version }}; + done From 28142a261068a9b2fa2442ded69f30be490a79e4 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 14:45:55 +0200 Subject: [PATCH 09/13] Update build.yml --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index afe1c2e34..103233271 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,9 +73,9 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max outputs: | - ${{ env.REGISTRY_IMAGES }} | while read image; do - echo "type=image,name=$image,push-by-digest=true,name-canonical=true,push=true"; - done + type=image,name=ghcr.io/tcgdex/server,push-by-digest=true,name-canonical=true,push=true + type=image,name=tcgdex/server,push-by-digest=true,name-canonical=true,push=true + - name: Export digest run: | From 69d28af85c502802cf1822910d0272dfa2ef1a0c Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 14:48:19 +0200 Subject: [PATCH 10/13] Update build.yml --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 103233271..fe8c9dcc9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,6 +20,12 @@ jobs: # - linux/arm/v7 - linux/arm64 steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Prepare run: | platform=${{ matrix.platform }} From 2efc86f3bb82870ce83206663ce59fa27c9e4bb0 Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 15:08:03 +0200 Subject: [PATCH 11/13] Update build.yml --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fe8c9dcc9..1c23526d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,7 @@ jobs: # - linux/arm/v6 # - linux/arm/v7 - linux/arm64 + name: Building TCGdex for ${{ matrix.platform }} steps: - name: Checkout @@ -79,8 +80,8 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max outputs: | - type=image,name=ghcr.io/tcgdex/server,push-by-digest=true,name-canonical=true,push=true - type=image,name=tcgdex/server,push-by-digest=true,name-canonical=true,push=true + type=image,name=ghcr.io/tcgdex/server,push-by-digest=true,name-canonical=true + type=image,name=tcgdex/server,push-by-digest=true,name-canonical=true - name: Export digest @@ -99,6 +100,7 @@ jobs: deploy: runs-on: ubuntu-latest + name: Deploying TCGdex if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} needs: - build From 1c0b3c368d69b6b5ead9af908882d98d3e2f8eaa Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 15:29:18 +0200 Subject: [PATCH 12/13] Update build.yml --- .github/workflows/build.yml | 83 +------------------------------------ 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1c23526d5..4f949206f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: ci +name: Build Docker image on: push: @@ -12,7 +12,6 @@ jobs: build: runs-on: ubuntu-latest strategy: - fail-fast: false matrix: platform: - linux/amd64 @@ -27,11 +26,6 @@ jobs: with: fetch-depth: 0 - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -78,79 +72,6 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha + push: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} cache-to: type=gha,mode=max - outputs: | - type=image,name=ghcr.io/tcgdex/server,push-by-digest=true,name-canonical=true - type=image,name=tcgdex/server,push-by-digest=true,name-canonical=true - - - - 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 - - deploy: - runs-on: ubuntu-latest - name: Deploying TCGdex - if: ${{ !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }} - 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: - images: ${{ env.REGISTRY_IMAGE }} - tags: | - type=edge - type=ref,event=pr - type=ref,event=branch,prefix=branch- - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=semver,pattern=latest - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to Github Packages - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_TOKEN }} - - - name: Create manifest list and push for each image - working-directory: /tmp/digests - run: | - echo "${{ env.REGISTRY_IMAGES }}" | while read image; do - docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ - $(printf "$image@sha256:%s " *); - done - - name: Inspect image - run: | - echo "${{ env.REGISTRY_IMAGES }}" | while read image; do - docker buildx imagetools inspect $image:${{ steps.meta.outputs.version }}; - done From ef1caff13c78b9a80e31d1af60df8e75df0ee62b Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 30 Aug 2024 17:06:46 +0200 Subject: [PATCH 13/13] Update build.yml --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f949206f..ed189c55f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,8 +17,8 @@ jobs: - linux/amd64 # - linux/arm/v6 # - linux/arm/v7 - - linux/arm64 - name: Building TCGdex for ${{ matrix.platform }} + # - linux/arm64 + name: Building TCGdex for #${{ matrix.platform }} steps: - name: Checkout @@ -62,12 +62,12 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push by digest + - name: Build and push id: build uses: docker/build-push-action@v6 with: context: . - platforms: ${{ matrix.platform }} + platforms: linux/amd64,linux/arm64 # ${{ matrix.platform }} file: ./Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}