Skip to content

Commit

Permalink
update cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBoot committed Nov 14, 2024
1 parent 5ec404d commit fb645b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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/[email protected]
with:
cache-map: |
{
"cache": "/cache"
"cache": {
"target": "/cache",
"id": "cache-${{ matrix.name }}-${{ matrix.features }}",
}
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

Expand All @@ -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 }}
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.cli
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit fb645b5

Please sign in to comment.