diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 50cf2d4..bb672ba 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -16,19 +16,19 @@ jobs: include: - name: "ghcr.io/bigboot/autokuma" dockerfile: Dockerfile - build_args: "" + features: "" tag_prefix: "" - name: "ghcr.io/bigboot/kuma" dockerfile: Dockerfile.cli - build_args: "" + features: "" tag_prefix: "" - name: "ghcr.io/bigboot/autokuma" dockerfile: Dockerfile - build_args: "FEATURES=uptime-kuma-v2" + features: "uptime-kuma-v2" tag_prefix: "uptime-kuma-v2-" - name: "ghcr.io/bigboot/kuma" dockerfile: Dockerfile.cli - build_args: "FEATURES=uptime-kuma-v2" + features: "uptime-kuma-v2" tag_prefix: "uptime-kuma-v2-" steps: @@ -73,14 +73,17 @@ jobs: with: path: | cache - key: cache-${{ runner.os }}-${{ runner.arch }}-cargo-${{ matrix.name }}-${{ matrix.tag_prefix }}-${{ hashFiles('**/Cargo.lock') }} + key: cache-${{ runner.os }}-cargo-${{ matrix.name }}-${{ hashFiles('**/Cargo.lock') }} - name: inject cache into docker uses: reproducible-containers/buildkit-cache-dance@v3.1.0 with: cache-map: | { - "cache": "/cache" + "cache": { + "target": "/cache", + "id": "cache-${{ matrix.name }}-${{ matrix.features }}", + } } skip-extraction: ${{ steps.cache.outputs.cache-hit }} @@ -94,7 +97,7 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - build-args: ${{ matrix.build_args }} + build-args: "FEATURES=${{ matrix.features }}" - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index a22d792..0477ac2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,11 @@ ARG FEATURES= FROM rust:1.81 AS builder ARG FEATURES +ARG TARGETARCH WORKDIR /usr/src/autokuma COPY . . -RUN --mount=type=cache,target=/cache,sharing=locked \ - cargo install --features "${FEATURES}" --locked --target-dir /cache --path ./autokuma +RUN --mount=type=cache,target=/cache/$TARGETARCH,id=cache-ghcr.io/bigboot/autokuma-${FEATURES} \ + cargo install --features "${FEATURES}" --locked --target-dir /cache/$TARGETARCH --path ./autokuma FROM debian:bookworm-slim RUN apt-get update && apt-get install -y \ diff --git a/Dockerfile.cli b/Dockerfile.cli index de80279..66c66cd 100644 --- a/Dockerfile.cli +++ b/Dockerfile.cli @@ -2,10 +2,11 @@ ARG FEATURES= FROM rust:1.81 AS builder ARG FEATURES +ARG TARGETARCH WORKDIR /usr/src/autokuma COPY . . -RUN --mount=type=cache,target=/cache,sharing=locked \ - cargo install --features "${FEATURES}" --locked --target-dir /cache --path ./kuma-cli +RUN --mount=type=cache,target=/cache/$TARGETARCH,id=cache-ghcr.io/bigboot/kuma-${FEATURES} \ + cargo install --features "${FEATURES}" --locked --target-dir /cache/$TARGETARCH --path ./kuma-cli FROM debian:bookworm-slim RUN apt-get update && apt-get install -y \