From 12ee9bb592aa5199ffbd105ca422b124befd7453 Mon Sep 17 00:00:00 2001 From: Nulo Date: Fri, 12 Jan 2024 18:52:59 -0300 Subject: [PATCH] ci: cache --- .github/workflows/container.yml | 30 ++++++++++++++++++++++++++++++ Dockerfile.scraper | 6 +++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index f64c1ee..ba0c925 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -75,6 +75,36 @@ jobs: uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/scraper + - name: Cache root-.cargo-git + uses: actions/cache@v3 + with: + path: root-.cargo-git + key: root-.cargo-git-${{ hashFiles('Dockerfile') }} + - name: inject root-.cargo-git into docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.3 + with: + cache-source: root-.cargo-git + cache-target: /root/.cargo/git + - name: Cache root-.cargo-registry + uses: actions/cache@v3 + with: + path: root-.cargo-registry + key: root-.cargo-registry-${{ hashFiles('Dockerfile') }} + - name: inject root-.cargo-registry into docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.3 + with: + cache-source: root-.cargo-registry + cache-target: /root/.cargo/registry + - name: Cache usr/src/app/target + uses: actions/cache@v3 + with: + path: usr/src/app/target + key: usr/src/app/target-${{ hashFiles('Dockerfile') }} + - name: inject usr/src/app/targetinto docker + uses: reproducible-containers/buildkit-cache-dance@v2.1.3 + with: + cache-source: usr/src/app/target + cache-target: /usr/src/app/target - name: Build and push Docker image uses: docker/build-push-action@v5 with: diff --git a/Dockerfile.scraper b/Dockerfile.scraper index 161b0eb..8494c5f 100644 --- a/Dockerfile.scraper +++ b/Dockerfile.scraper @@ -6,9 +6,9 @@ FROM base as rs-build RUN apk add --no-cache rust build-base sqlite-dev COPY scraper-rs/ . -RUN --mount=type=cache,target=/root/.cargo/git \ - --mount=type=cache,target=/root/.cargo/registry \ - --mount=type=cache,sharing=private,target=/usr/src/app/target \ +RUN --mount=type=cache,sharing=locked,target=/root/.cargo/git \ + --mount=type=cache,sharing=locked,target=/root/.cargo/registry \ + --mount=type=cache,sharing=locked,target=/usr/src/app/target \ cargo install --locked --path . FROM base