Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,28 @@ jobs:
#- linux/arm64
steps:
- uses: actions/checkout@v5

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

# Build and push with docker buildx
- name: Setup docker buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkitd.toml

- name: Configure tags based on git tags + latest
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=pep440,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=pr
buildkitd-config: .github/buildkitd.toml

- name: Rust Build Cache for Docker
uses: actions/cache@v4
id: cache
with:
path: rust-build-cache
key: ${{ runner.os }}-build-cache-${{ hashFiles('**/Cargo.toml') }}
path: |
target
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-build-cache2-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os}}-build-cache2
- name: Create folders on cache miss
run: mkdir -p ~/.cargo/{git,registry} && mkdir -p target

- name: Inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3
Expand All @@ -58,7 +54,17 @@ jobs:
"~/.cargo/registry": "/root/.cargo/registry",
"~/.cargo/git": "/root/.cargo/git"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
# skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Configure tags based on git tags + latest
uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=pep440,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=pr

- name: Docker login
uses: docker/login-action@v3
Expand All @@ -78,10 +84,10 @@ jobs:
# when using buildkit-cache-dance
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ matrix.platform }}
sbom: true

lint:
runs-on: ubuntu-latest
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ COPY Cargo.* .
COPY version.rs version.rs
RUN --mount=type=cache,target=/volume/target \
--mount=type=cache,target=/root/.cargo/registry \
cargo build --release --bin version && \
mv /volume/target/x86_64-unknown-linux-musl/release/version .
cargo install --bin version --path=.

FROM cgr.dev/chainguard/static
COPY --from=builder --chown=nonroot:nonroot /volume/version /app/
COPY --from=builder --chown=nonroot:nonroot /opt/cargo/bin/version /app/
EXPOSE 8080
ENTRYPOINT ["/app/version"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ $ curl 0.0.0.0:8000/versions/default/foo-controller
- In-cluster: edit and `tilt up` [*](https://tilt.dev/)
- Docker build: `just build`

NB: images + docker dev is `linux/amd64` only atm.
NB: pushed images are `linux/amd64` only atm, but local docker build works on `linux/arm64` also.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ release:

[private]
import:
k3d image import ghcr.io/kube-rs/version-rs:local --cluster main
k3d image import ghcr.io/kube-rs/version-rs:local -c=$(k3d cluster list -ojson |jq '.[0].name' -r)
sd "image: .*" "image: ghcr.io/kube-rs/version-rs:local" deployment.yaml
kubectl apply -f deployment.yaml
2 changes: 1 addition & 1 deletion version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn main() -> anyhow::Result<()> {

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