Skip to content

Commit

Permalink
try: github cache to enable cross-build caching
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhan committed Aug 8, 2022
1 parent 54a1f65 commit 89f427b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions actions/serverless_prod_deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ runs:
shell: bash
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Copy user code template file
uses: dagster-io/dagster-cloud-action/actions/utils/copy_template@yuhan/08-07-use_--mount_type_cache_to_explicitly_cache_pip_downloads
with:
Expand All @@ -45,8 +52,12 @@ runs:
tags: "${{ env.REGISTRY_URL }}:${{ github.sha }}"
labels: |
branch=${{ github.head_ref }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Deploy to Dagster Cloud
uses: dagster-io/dagster-cloud-action/actions/utils/deploy@main
id: deploy
Expand Down
2 changes: 1 addition & 1 deletion src/Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /opt/dagster/app
COPY . /opt/dagster/app

# Create caches for pip installs
RUN --mount=type=cache,target=/root/.cache/pip if [ -f "requirements.txt" ]; then \
RUN --mount=type=cache,target=/tmp/.buildx-cache/.cache/pip if [ -f "requirements.txt" ]; then \
pip install -r requirements.txt; \
else \
pip install .; \
Expand Down

0 comments on commit 89f427b

Please sign in to comment.