Skip to content

Commit 5925912

Browse files
authored
arm buildability in docker (#162)
* mvp arm buildability in docker Signed-off-by: clux <[email protected]> * actually fix build - sneaky axum issue Signed-off-by: clux <[email protected]> * clarify Signed-off-by: clux <[email protected]> * ping hooks - 2025-11-27 Signed-off-by: clux <[email protected]> * is this a thing? Signed-off-by: clux <[email protected]> * try a thing Signed-off-by: clux <[email protected]> * always extract? Signed-off-by: clux <[email protected]> * warning Signed-off-by: clux <[email protected]> * another test Signed-off-by: clux <[email protected]> * min? Signed-off-by: clux <[email protected]> * also target Signed-off-by: clux <[email protected]> * reverse order Signed-off-by: clux <[email protected]> * ping hooks - 2025-11-27 Signed-off-by: clux <[email protected]> * ugh try something else Signed-off-by: clux <[email protected]> * ping hooks - 2025-11-27 Signed-off-by: clux <[email protected]> * this doesn't get me very far Signed-off-by: clux <[email protected]> * ugh Signed-off-by: clux <[email protected]> * destructor ordering? Signed-off-by: clux <[email protected]> * different order, different paths Signed-off-by: clux <[email protected]> * ping hooks - 2025-11-27 Signed-off-by: clux <[email protected]> * maybe with load Signed-off-by: clux <[email protected]> --------- Signed-off-by: clux <[email protected]>
1 parent 347b79e commit 5925912

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,28 @@ jobs:
2222
#- linux/arm64
2323
steps:
2424
- uses: actions/checkout@v5
25-
2625
- name: Set up QEMU
2726
uses: docker/setup-qemu-action@v3
2827

2928
# Build and push with docker buildx
3029
- name: Setup docker buildx
3130
uses: docker/setup-buildx-action@v3
3231
with:
33-
config: .github/buildkitd.toml
34-
35-
- name: Configure tags based on git tags + latest
36-
uses: docker/metadata-action@v5
37-
id: meta
38-
with:
39-
images: ghcr.io/${{ github.repository }}
40-
tags: |
41-
type=pep440,pattern={{version}}
42-
type=raw,value=latest,enable={{is_default_branch}}
43-
type=ref,event=pr
32+
buildkitd-config: .github/buildkitd.toml
4433

4534
- name: Rust Build Cache for Docker
4635
uses: actions/cache@v4
4736
id: cache
4837
with:
49-
path: rust-build-cache
50-
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/Cargo.toml') }}
38+
path: |
39+
target
40+
~/.cargo/registry
41+
~/.cargo/git
42+
key: ${{ runner.os }}-build-cache2-${{ hashFiles('**/Cargo.toml') }}
43+
restore-keys: |
44+
${{ runner.os}}-build-cache2
45+
- name: Create folders on cache miss
46+
run: mkdir -p ~/.cargo/{git,registry} && mkdir -p target
5147

5248
- name: Inject cache into docker
5349
uses: reproducible-containers/buildkit-cache-dance@v3
@@ -58,7 +54,17 @@ jobs:
5854
"~/.cargo/registry": "/root/.cargo/registry",
5955
"~/.cargo/git": "/root/.cargo/git"
6056
}
61-
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
57+
# skip-extraction: ${{ steps.cache.outputs.cache-hit }}
58+
59+
- name: Configure tags based on git tags + latest
60+
uses: docker/metadata-action@v5
61+
id: meta
62+
with:
63+
images: ghcr.io/${{ github.repository }}
64+
tags: |
65+
type=pep440,pattern={{version}}
66+
type=raw,value=latest,enable={{is_default_branch}}
67+
type=ref,event=pr
6268
6369
- name: Docker login
6470
uses: docker/login-action@v3
@@ -78,10 +84,10 @@ jobs:
7884
# when using buildkit-cache-dance
7985
cache-from: type=gha
8086
cache-to: type=gha,mode=max
87+
load: true
8188
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}
8289
tags: ${{ steps.meta.outputs.tags }}
8390
platforms: ${{ matrix.platform }}
84-
sbom: true
8591

8692
lint:
8793
runs-on: ubuntu-latest

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ COPY Cargo.* .
33
COPY version.rs version.rs
44
RUN --mount=type=cache,target=/volume/target \
55
--mount=type=cache,target=/root/.cargo/registry \
6-
cargo build --release --bin version && \
7-
mv /volume/target/x86_64-unknown-linux-musl/release/version .
6+
cargo install --bin version --path=.
87

98
FROM cgr.dev/chainguard/static
10-
COPY --from=builder --chown=nonroot:nonroot /volume/version /app/
9+
COPY --from=builder --chown=nonroot:nonroot /opt/cargo/bin/version /app/
1110
EXPOSE 8080
1211
ENTRYPOINT ["/app/version"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ $ curl 0.0.0.0:8000/versions/default/foo-controller
3434
- In-cluster: edit and `tilt up` [*](https://tilt.dev/)
3535
- Docker build: `just build`
3636

37-
NB: images + docker dev is `linux/amd64` only atm.
37+
NB: pushed images are `linux/amd64` only atm, but local docker build works on `linux/arm64` also.

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ release:
1717

1818
[private]
1919
import:
20-
k3d image import ghcr.io/kube-rs/version-rs:local --cluster main
20+
k3d image import ghcr.io/kube-rs/version-rs:local -c=$(k3d cluster list -ojson |jq '.[0].name' -r)
2121
sd "image: .*" "image: ghcr.io/kube-rs/version-rs:local" deployment.yaml
2222
kubectl apply -f deployment.yaml

version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async fn main() -> anyhow::Result<()> {
6969

7070
let app = Router::new()
7171
.route("/versions", routing::get(get_versions))
72-
.route("/versions/:namespace/:name", routing::get(get_version))
72+
.route("/versions/{namespace}/{name}", routing::get(get_version))
7373
.with_state(reader) // routes can read from the reflector store
7474
.layer(tower_http::trace::TraceLayer::new_for_http())
7575
// NB: routes added after TraceLayer are not traced

0 commit comments

Comments
 (0)