Skip to content

Commit

Permalink
store cache in S3
Browse files Browse the repository at this point in the history
  • Loading branch information
henryjw committed May 4, 2024
1 parent eaedba6 commit 5fc21ae
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 4 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ jobs:
with:
images: Build

- name: Cache
uses: actions/cache@v3
- name: Cache (S3)
uses: tespkg/actions-cache@v1
id: cache
with:
bucket: gha-docker-npm-caching-example
accessKey: ${{ vars.AWS_ACCESS_KEY }}
secretKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
use-fallback: false # No fallback since the purpose of this example is to demonstrate the cache to S3
path: |
pnpm
key: cache-${{ hashFiles('pnpm-lock.yaml') }}
key: pnpm-cache-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-cache-
- name: inject cache into docker
uses: reproducible-containers/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ WORKDIR /app
COPY . .

RUN --mount=type=cache,target=/pnpm \
pnpm install --frozen-lockfile
pnpm config set store-dir ${PNPM_HOME} && \
pnpm install --frozen-lockfile --prefer-offline

# Use a smaller Node.js image for the final image
FROM node:alpine AS prod
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@aws-sdk/core": "^3.567.0",
"aws-sdk": "^2.1613.0",
"express": "^4.19.2",
"node-gyp": "^10.1.0",
"s3-zip": "^3.3.0",
Expand Down
Loading

0 comments on commit 5fc21ae

Please sign in to comment.