Skip to content

Commit edb1853

Browse files
committed
ci: build and test each image in one job
The test job and the build job built the same image twice. Both used the docker-container buildx driver, so each one serialized the image to a tar stream and imported it back. On fx that export cost 3m15s of a 5m36s step, and the gha cache gave no hits because any version bump invalidates the single large RUN layer, while the cache export cost 81s per run. One job now builds with the default buildx driver, which writes straight into the local daemon, runs the smoke test, and pushes only from master. QEMU setup is gone because every image is linux/amd64. The smoke test uses the variant tag, so it checks the exact image that is pushed. Expect fx to drop from about 12m to about 3m30s.
1 parent d00dce8 commit edb1853

2 files changed

Lines changed: 14 additions & 43 deletions

File tree

‎.github/workflows/docker.yml‎

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
test:
16-
name: "Test (${{ matrix.image }})"
15+
build:
16+
name: "Build (${{ matrix.image }})"
1717
runs-on: ubuntu-latest
1818
strategy:
1919
fail-fast: false
@@ -23,56 +23,23 @@ jobs:
2323
- name: Checkout
2424
uses: actions/checkout@v6
2525

26-
- name: Set up Docker Buildx
27-
uses: docker/setup-buildx-action@v4
28-
29-
- name: Build image for testing
30-
uses: docker/build-push-action@v7
31-
with:
32-
context: ./${{ matrix.image }}
33-
file: ./${{ matrix.image }}/Dockerfile
34-
push: false
35-
tags: dockette/coder:${{ matrix.image }}-test
36-
platforms: linux/amd64
37-
load: true
26+
# Builds into the local Docker daemon, so no export or import step
27+
- name: Build image
28+
run: make build DOCKER_VARIANT=${{ matrix.image }}
3829

3930
- name: Smoke test image
40-
run: make test DOCKER_VARIANT=${{ matrix.image }} DOCKER_TAG=${{ matrix.image }}-test
41-
42-
build:
43-
name: "Build (${{ matrix.image }})"
44-
needs: test
45-
runs-on: ubuntu-latest
46-
strategy:
47-
fail-fast: false
48-
matrix:
49-
image: [fx, php, nodejs, golang, python]
50-
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v6
31+
run: make test DOCKER_VARIANT=${{ matrix.image }}
5332

5433
- name: Login to DockerHub
34+
if: ${{ github.ref == 'refs/heads/master' }}
5535
uses: docker/login-action@v4
5636
with:
5737
username: ${{ secrets.DOCKERHUB_USERNAME }}
5838
password: ${{ secrets.DOCKERHUB_TOKEN }}
5939

60-
- name: Set up QEMU
61-
uses: docker/setup-qemu-action@v4
62-
63-
- name: Set up Docker Buildx
64-
uses: docker/setup-buildx-action@v4
65-
66-
- name: Build and push
67-
uses: docker/build-push-action@v7
68-
with:
69-
context: ./${{ matrix.image }}
70-
file: ./${{ matrix.image }}/Dockerfile
71-
push: ${{ github.ref == 'refs/heads/master' }}
72-
tags: dockette/coder:${{ matrix.image }}
73-
platforms: linux/amd64
74-
cache-from: type=gha,scope=${{ matrix.image }}
75-
cache-to: type=gha,scope=${{ matrix.image }},mode=max
40+
- name: Push image
41+
if: ${{ github.ref == 'refs/heads/master' }}
42+
run: make push DOCKER_VARIANT=${{ matrix.image }}
7643

7744
docs:
7845
name: "Docs"

‎Makefile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ build-all:
1717
$(MAKE) build DOCKER_VARIANT=golang
1818
$(MAKE) build DOCKER_VARIANT=python
1919

20+
.PHONY: push
21+
push:
22+
docker push ${DOCKER_IMAGE}:${DOCKER_TAG}
23+
2024
.PHONY: run
2125
run:
2226
docker run --rm -it --platform ${DOCKER_PLATFORMS} ${DOCKER_IMAGE}:${DOCKER_TAG}

0 commit comments

Comments
 (0)