Skip to content

Commit

Permalink
perf: using cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Jul 17, 2024
1 parent 89fda33 commit 412908e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/build-base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,27 @@ jobs:
id: repo
run: echo "REPO=$(basename ${{ github.repository }})" >> $GITHUB_ENV

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build and push multi-arch image
run: |
DOCKER_BUILDKIT=1 docker buildx build \
--platform linux/amd64,linux/arm64 \
-f Dockerfile-base \
-t jumpserver/${{ env.REPO }}-base:${{ env.IMAGE_TAG }} \
--build-arg BUILDKIT_INLINE_CACHE=1 \
--push .
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
file: Dockerfile-base
tags: jumpserver/${{ env.REPO }}-base:${{ env.IMAGE_TAG }}
cache-from: type=registry
cache-to: type=inline

- name: Update Dockerfile
run: |
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN set -ex \

WORKDIR /data


COPY package.json yarn.lock ./
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=yarn-cache \
yarn install

0 comments on commit 412908e

Please sign in to comment.