diff --git a/.github/workflows/matrix-tools.yml b/.github/workflows/matrix-tools.yml index 177cbf8e..9766e51f 100644 --- a/.github/workflows/matrix-tools.yml +++ b/.github/workflows/matrix-tools.yml @@ -1,8 +1,8 @@ -# Copyright 2024 New Vector Ltd +# Copyright 2025 New Vector Ltd # # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial -name: Build Docker Images +name: Build matrix-tool Docker Images on: pull_request_target: @@ -14,8 +14,7 @@ on: - 'matrix-tools-*' env: - DOCKER_REGISTRY: ghcr.io/${{ github.repository }} - BAKE_TARGET: matrix-tools + REGISTRY_IMAGE: ghcr.io/${{ github.repository }}/matrix-tools permissions: contents: read @@ -55,54 +54,49 @@ jobs: - tests runs-on: ubuntu-latest steps: - - name: Inspect Builder - run: docker buildx inspect + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: Checkout Repository - uses: actions/checkout@v4 + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Login to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Get Release Tag - if: github.ref_type == 'tag' # Only for GitHub releases - run: | - echo "Converting $GITHUB_REF to tags" - echo "VERSION=${GITHUB_REF#refs\/tags\/matrix-tools-}" >> $GITHUB_ENV + - name: Get Release Tag + if: github.ref_type == 'tag' # Only for GitHub releases + run: | + echo "Converting $GITHUB_REF to tags" + echo "VERSION=${GITHUB_REF#refs\/tags\/matrix-tools-}" >> $GITHUB_ENV - - name: Docker meta - id: meta - uses: docker/metadata-action@master - with: - images: | - ${{ env.DOCKER_REGISTRY }}/${{ env.BAKE_TARGET }} - flavor: | - latest=false - tags: | - type=raw,value=${{ env.VERSION }},enable=${{ github.ref_type == 'tag' }} - type=sha,prefix=sha-,format=short + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.REGISTRY_IMAGE }} + flavor: | + latest=false + tags: | + type=raw,value=${{ env.VERSION }},enable=${{ github.ref_type == 'tag' }} + type=sha,prefix=sha-,format=short + labels: | + org.opencontainers.image.licenses=AGPL-3.0-only OR LicenseRef-Element-Commercial + annotations: | + org.opencontainers.image.licenses=AGPL-3.0-only OR LicenseRef-Element-Commercial - - name: Build and Push Image - id: build_image - uses: docker/bake-action@v4.1.0 - with: - # Only for tags - push: "${{ github.ref_type == 'tag' }}" - files: | - docker-bake.hcl - ${{ steps.meta.outputs.bake-file }} - targets: | - ${{ env.BAKE_TARGET }} - # Override the docker bake target with Bakefile options specific to - # releasing the docker images. - # - # All options: https://docs.docker.com/reference/cli/docker/buildx/bake/#set - # Option descriptions: https://docs.docker.com/build/bake/reference/ - # - # note: "base" is the target called "base". - set: | - base.output=type=image + - name: Build and Push Image + uses: docker/bake-action@v6 + with: + push: "${{ github.ref_type == 'tag' }}" + files: | + docker-bake.hcl + cwd://${{ steps.meta.outputs.bake-file }} + targets: matrix-tools + set: | + *.output=type=image + *.platform=linux/amd64,linux/arm64 diff --git a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 index 6587f9a1..f7f52aa0 100644 --- a/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 +++ b/charts/matrix-stack/source/common/sub_schema_values.yaml.j2 @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial ## The matrix-tools iamge, used in multiple components matrixTools: -{{ image(registry="ghcr.io", repository="element-hq/ess-helm/matrix-tools", tag="0.2.1") | indent(2) }} +{{ image(registry="ghcr.io", repository="element-hq/ess-helm/matrix-tools", tag="0.3.0") | indent(2) }} ## The server name of the Matrix Stack. This gets embedded in user IDs & room IDs ## It can not change after the initial deployment. diff --git a/charts/matrix-stack/values.yaml b/charts/matrix-stack/values.yaml index 0fe95d4b..28990c08 100644 --- a/charts/matrix-stack/values.yaml +++ b/charts/matrix-stack/values.yaml @@ -20,7 +20,7 @@ matrixTools: ## The tag of the container image to use. ## Defaults to the Chart's appVersion if not set - tag: "0.2.1" + tag: "0.3.0" ## Container digest to use. Used to pull the image instead of the image tag / Chart appVersion if set # digest: diff --git a/docker-bake.hcl b/docker-bake.hcl index d6ddce67..90375a4b 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -5,18 +5,8 @@ // Targets filled by GitHub Actions: one for the regular tag target "docker-metadata-action" {} -// This sets the platforms and is further extended by GitHub Actions to set the -// output and the cache locations -target "base" { - platforms = [ - "linux/amd64", - // "linux/arm64", - ] -} - -// Top-level target to build the matrix-tools container image target "matrix-tools" { - inherits = ["base", "docker-metadata-action"] + inherits = ["docker-metadata-action"] dockerfile = "Dockerfile" context = "./matrix-tools" } diff --git a/matrix-tools/Dockerfile b/matrix-tools/Dockerfile index 2087586e..4b762c2d 100644 --- a/matrix-tools/Dockerfile +++ b/matrix-tools/Dockerfile @@ -2,19 +2,20 @@ # # SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial -FROM golang:1.23 AS buildstage +FROM --platform=${BUILDPLATFORM} golang:1.23 AS buildstage WORKDIR /app COPY . /app + RUN go mod download -RUN CGO_ENABLED=0 go build -o /app/matrix-tools cmd/main.go -RUN chmod 755 /app/matrix-tools + +ARG TARGETOS TARGETARCH +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o /app/matrix-tools cmd/main.go FROM gcr.io/distroless/static-debian12 -LABEL org.opencontainers.image.licenses="AGPL-3.0-only OR LicenseRef-Element-Commercial" WORKDIR / -COPY --from=buildstage /app/matrix-tools / +COPY --from=buildstage --chmod=0755 /app/matrix-tools / EXPOSE 8443 ENTRYPOINT ["/matrix-tools"] diff --git a/newsfragments/170.changed.md b/newsfragments/170.changed.md new file mode 100644 index 00000000..78962813 --- /dev/null +++ b/newsfragments/170.changed.md @@ -0,0 +1 @@ +Support arm64 in matrix-tools image.