Skip to content

Instantly share code, notes, and snippets.

@alvistar
Created May 4, 2020 14:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvistar/5a5d241bf79893cf518884bf66cb9a5d to your computer and use it in GitHub Desktop.
Save alvistar/5a5d241bf79893cf518884bf66cb9a5d to your computer and use it in GitHub Desktop.
Buildx cache example for Github Actions
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install buildx
uses: crazy-max/ghaction-docker-buildx@v1
with:
buildx-version: latest
qemu-version: latest
- name: docker login
env:
USERNAME: ${{ secrets.DOCKER_USERNAME }}
PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login -p $PASSWORD -u $USERNAME your-registry.com
- name: cache docker cache
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/cache
key: ${{ runner.os }}-docker-${{ hashfiles('cache/**') }}
restore-keys: |
${{ runner.os }}-docker-
- name: build docker image
run: >
docker buildx build
--cache-from "type=local,src=$GITHUB_WORKSPACE/cache"
--cache-to "type=local,dest=$GITHUB_WORKSPACE/cache"
--output "type=image, name=your_image:CI,push=false"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment