From b43004bd0beca9dde3c2c8a8f359a4a471eb6eee Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 19:31:00 +0000 Subject: [PATCH 1/6] Docker: `poetry install` verbosely --- .github/workflows/pipeline.yml | 16 ++++++++++++++++ Dockerfile | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 61fe037e..73af83e1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -59,6 +59,22 @@ jobs: packaging: uses: "matrix-org/backend-meta/.github/workflows/packaging.yml@v1" + docker: + # Sanity check that we can build the x64 image + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + uses: docker/build-push-action@v4 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + push: false + run-tests: name: Tests if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail diff --git a/Dockerfile b/Dockerfile index 00f7e00d..86e9ad20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ COPY --chown=sydent:sydent ["sydent", "sydent"] COPY --chown=sydent:sydent ["README.rst", "pyproject.toml", "poetry.lock", "./"] # Install dependencies -RUN python -m poetry install --no-dev --no-interaction --extras "prometheus sentry" +RUN python -m poetry install -vv --no-dev --no-interaction --extras "prometheus sentry" # Record dependencies for posterity RUN python -m poetry export -o requirements.txt From c733ced9c8ec1acdd91443cada1d9c83e221dbba Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 19:40:02 +0000 Subject: [PATCH 2/6] Now try building on ARM --- .github/workflows/pipeline.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 73af83e1..f79b1e62 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -66,13 +66,15 @@ jobs: - uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - name: Build image uses: docker/build-push-action@v4 with: cache-from: type=gha cache-to: type=gha,mode=max context: . + platforms: "linux/amd64,linux/arm64" push: false run-tests: From 2b1cdea8aa4ca505379ceac40b8f717a3fd8598a Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 19:55:53 +0000 Subject: [PATCH 3/6] Don't use workflow repo's docker workflow This config seemed to build arm wheels much more quickly and I've no idea why!?!! --- .github/workflows/docker.yml | 49 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 76300a01..a068f565 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,16 +2,49 @@ name: Docker on: push: + branches: ["main"] tags: ["v*"] - branches: [ main ] + +env: + PLATFORMS: "linux/amd64,linux/arm64" jobs: build: name: Build and publish images - uses: "matrix-org/backend-meta/.github/workflows/docker.yml@v1" - with: - image-name: matrixdotorg/sydent - publish: true - secrets: - DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} - DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: docker/setup-qemu-action@v2 + with: + platforms: ${{ env.PLATFORMS }} + - uses: docker/setup-buildx-action@v2 + - uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build main Sydent image + if: github.ref_name == 'main' + uses: docker/build-push-action@v4 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + platforms: ${{ env.PLATFORMS }} + push: true + tags: | + matrixdotorg/sydent:main + + - name: Build release Sydent image + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + id: docker_build_sliding_sync_release + uses: docker/build-push-action@v4 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + platforms: ${{ env.PLATFORMS }} + push: true + tags: | + matrixdotorg/sydent:latest + matrixdotorg/sydent:${{ github.ref_name }} From 7ddc056860bdc7026d54f0debf3cf6cccbab446d Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 19:58:02 +0000 Subject: [PATCH 4/6] Changelog --- changelog.d/584.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/584.misc diff --git a/changelog.d/584.misc b/changelog.d/584.misc new file mode 100644 index 00000000..26449ea0 --- /dev/null +++ b/changelog.d/584.misc @@ -0,0 +1 @@ +Inline docker job definition in this repo, and update docker-related action versions. From 361764943f206339c95d3f96f469e42af7874c8c Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 19:58:34 +0000 Subject: [PATCH 5/6] Revert "Now try building on ARM" This reverts commit c733ced9c8ec1acdd91443cada1d9c83e221dbba. --- .github/workflows/pipeline.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f79b1e62..73af83e1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -66,15 +66,13 @@ jobs: - uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + - name: Build image uses: docker/build-push-action@v4 with: cache-from: type=gha cache-to: type=gha,mode=max context: . - platforms: "linux/amd64,linux/arm64" push: false run-tests: From 801629308e66eb484f54635612e2f856f3c94a43 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Mon, 20 Nov 2023 20:14:25 +0000 Subject: [PATCH 6/6] Remove bad copypasta --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a068f565..d7005acb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -37,7 +37,6 @@ jobs: - name: Build release Sydent image if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - id: docker_build_sliding_sync_release uses: docker/build-push-action@v4 with: cache-from: type=gha