A GitHub Action that builds and pushes Docker images with multi-stage caching to drastically reduce CI build times.
Docker Build with Cache Action is a GitHub Action that builds Docker images with intelligent layer caching to speed up CI/CD pipelines. It caches each stage of multi-stage Docker builds, pushing and pulling these cached stages from a registry to avoid rebuilding unchanged layers. This solves the problem of slow Docker builds in continuous integration by reusing previously built stages across workflow runs.
Developers and DevOps engineers using GitHub Actions for CI/CD who build Docker images and want to reduce build times, especially those with multi-stage Dockerfiles or complex build processes.
Developers choose this action because it automates Docker layer caching in a registry-agnostic way, supports multi-stage builds and Docker Compose, and integrates seamlessly with major container registries. Its unique selling point is the ability to cache and reuse individual stages, which is more granular and effective than standard Docker caching.
:octocat: Build and push docker images caching each stage to reduce build time
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Caches each stage of multi-stage Docker builds by pushing and pulling layers from a registry, significantly reducing build times for complex Dockerfiles. This is core to its value proposition as described in the README.
Works out-of-the-box with major registries like Docker Hub, AWS ECR, GitHub Container Registry, and Google Cloud Registry, minimizing setup friction. The README provides specific examples for each.
Can parse and build images from Docker Compose files, including support for multiple file overrides and service filtering via regex. This is highlighted as a key feature with practical examples.
Allows conditional image pushing based on workflow triggers (e.g., push or pull_request events) or custom test commands, giving users control over when images are published. The README details this in the push_image_and_stages input.
When BuildKit is enabled (default for performance), cache functionality does not work with the deprecated docker.pkg.github.com registry, forcing users to migrate to ghcr.io or disable BuildKit. This is explicitly noted in the README's 'Action supercharged' section.
Cache effectiveness depends on careful management of base image tags and can be invalidated by Docker limitations, as admitted in the 'Cache is not working?' section, requiring user vigilance to avoid rebuilds.
When using Docker Compose files with services targeting different registries, the action requires multiple configurations, increasing setup complexity and potential for errors. The README warns about this in the compose_file input description.