Skip to content

Commit debff37

Browse files
authored
Multi-arch build (#19)
* multi-arch build take one * fix platform typo * fix another typo * include setup-qemu-action so we can build multi-platform * use buildx to build * see if single-arch works * add --load to Docker build command * try another lengthy multi-arch build now that we think the issues are fixed * try to build and push the images in one go... * build and push in one go * remove unnecessary Makefile variable * remove deprecate variable
1 parent 48456e6 commit debff37

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

.github/workflows/main-push.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
kubeconform:
1818
name: Kubeconform
1919
uses: ./.github/workflows/kubeconform.yml
20-
build:
21-
name: Build
22-
uses: ./.github/workflows/build.yml
20+
publish:
21+
name: Publish
22+
uses: ./.github/workflows/publish.yml
2323
secrets: inherit
2424
needs: [test, lint, end-to-end, kubeconform]
2525
with:
2626
version: '${{ github.sha }}'
27-
push: true
27+
platforms: 'linux/amd64,linux/arm64'

.github/workflows/build.yml .github/workflows/publish.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,33 @@ on:
55
required: true
66
type: string
77
description: 'The built image will be tagged with this version'
8-
push:
9-
required: false
10-
type: boolean
11-
default: false
12-
description: 'Whether to push the built image'
8+
platforms:
9+
required: true
10+
type: string
11+
default: 'linux/amd64'
12+
description: 'Platform(s) for which to build the image. Example: "linux/amd64,linux/arm64".'
1313

1414
jobs:
15-
build:
15+
publish:
1616
name: Image
1717
permissions:
1818
contents: read
1919
runs-on: ubuntu-22.04
2020
steps:
2121
- name: Checkout
2222
uses: actions/checkout@v4
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
2325
- name: Set up Docker
2426
uses: docker/setup-buildx-action@v3
2527
- name: Construct image tag
2628
id: tag
2729
run: echo "tag=${{ secrets.DOCKERHUB_USERNAME }}/tainter:${{ inputs.version }}" >> "$GITHUB_OUTPUT"
28-
- name: Build image
29-
run: IMAGE_TAG=${{ steps.tag.outputs.tag }} make image
30-
- name: Login
30+
- name: Log in
3131
uses: docker/login-action@v3
3232
with:
3333
username: ${{ secrets.DOCKERHUB_USERNAME }}
3434
password: ${{ secrets.DOCKERHUB_TOKEN }}
35-
- name: Push image
36-
if: inputs.push == true
35+
- name: Build and push image
3736
run: |
38-
docker image push ${{ steps.tag.outputs.tag }}
37+
docker buildx build --push --tag ${{ steps.tag.outputs.tag }} --platform ${{ inputs.platforms }} .

.github/workflows/tag-push.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ jobs:
1212
lint:
1313
name: Lint
1414
uses: ./.github/workflows/lint.yml
15-
build:
16-
name: Build
17-
uses: ./.github/workflows/build.yml
15+
end-to-end:
16+
name: End-to-end
17+
uses: ./.github/workflows/test-end-to-end.yml
18+
kubeconform:
19+
name: Kubeconform
20+
uses: ./.github/workflows/kubeconform.yml
21+
publish:
22+
name: Publish
23+
uses: ./.github/workflows/publish.yml
1824
secrets: inherit
19-
needs: [test, lint]
25+
needs: [test, lint, end-to-end, kubeconform]
2026
with:
2127
# https://github.com/orgs/community/discussions/26686#discussioncomment-3396593.
2228
version: '${{ github.ref_name }}'
23-
push: true
29+
platforms: 'linux/amd64,linux/arm64'

Dockerfile

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.82.0-slim-bookworm as base
1+
FROM rust:1.82.0-slim-bookworm AS base
22
RUN cargo install cargo-chef --version 0.1.68
33

44
FROM base AS planner
@@ -20,4 +20,9 @@ RUN groupadd -g 10001 tainter && \
2020
useradd -u 10000 -g tainter tainter \
2121
&& chown -R tainter:tainter /usr/local/bin/tainter
2222
USER tainter:tainter
23+
24+
LABEL org.opencontainers.image.title="tainter"
25+
LABEL org.opencontainers.image.source="https://github.com/LasseHels/tainter"
26+
LABEL org.opencontainers.image.authors="Lasse Canth Hels <lasse@hels.dk>"
27+
2328
ENTRYPOINT ["/usr/local/bin/tainter"]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ build:
4444
.PHONY: image
4545
image:
4646
@echo "Building image with tag $(IMAGE_TAG)"
47-
docker build -t $(IMAGE_TAG) .
47+
docker build --tag $(IMAGE_TAG) .
4848

4949
.PHONY: run-image
5050
run-image:

0 commit comments

Comments
 (0)