Git Product home page Git Product logo

action-docker-layer-caching's Introduction

Docker Layer Caching in GitHub Actions Readme Test status is unavailable CI status is unavailable

Enable Docker Layer Caching by adding a single line in GitHub Actions. This GitHub Action speeds up the building of docker images in your GitHub Actions workflow.

You can run docker build and docker-compose build in your GitHub Actions workflow using the cache with no special configuration, and it also supports multi-stage builds.

This GitHub Action uses the docker save / docker load command and the @actions/cache library.

⚠️ Deprecation Notice for v0.0.4 and older ⚠️

The author had not considered a large number of layers to be cached, so those versions process all layers in parallel. (#12)
Please update to version v0.0.5 with limited concurrency to avoid overloading the cache service.

Example workflows

Docker Compose

name: CI

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    # Pull the latest image to build, and avoid caching pull-only images.
    # (docker pull is faster than caching in most cases.)
    - run: docker-compose pull

    # In this step, this action saves a list of existing images,
    # the cache is created without them in the post run.
    # It also restores the cache if it exists.
    - uses: satackey/[email protected]
      # Ignore the failure of a step and avoid terminating the job.
      continue-on-error: true

    - run: docker-compose up --build

    # Finally, "Post Run satackey/[email protected]",
    # which is the process of saving the cache, will be executed.

docker build

name: CI

on: push

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    # In this step, this action saves a list of existing images,
    # the cache is created without them in the post run.
    # It also restores the cache if it exists.
    - uses: satackey/[email protected]
      # Ignore the failure of a step and avoid terminating the job.
      continue-on-error: true

    - name: Build the Docker image
      run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

    # Finally, "Post Run satackey/[email protected]",
    # which is the process of saving the cache, will be executed.

Inputs

See action.yml for details.

By default, the cache is separated by the workflow name. You can also set the cache key manually, like the official actions/cache action.

    - uses: satackey/[email protected]
      # Ignore the failure of a step and avoid terminating the job.
      continue-on-error: true
      with:
        key: foo-docker-cache-{hash}
        restore-keys: |
          foo-docker-cache-

Note: You must include {hash} in the key input. ({hash} is replaced by the hash value of the docker image when the action is executed.)

action-docker-layer-caching's People

Contributors

btkostner avatar dependabot[bot] avatar rcowsill avatar satackey avatar woa7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.