Is there any way to cache build dependencies using AWS CodeBuild?
Unsigned's answer is good but is a tad outdated. As of February 2019, CodeBuild allows both caching in an S3 bucket and allows the user to cache locally. You can now specify cache at 3 different layers of a build:
- Docker Layer Caching
- Git Layer Cahing (cache the last build and then only build from
git diff
) - Custom caching - specified within the
cache:
portion of your buildspec.yml file. Personally, I cache my node_modules/ here and then cache at the Git Layer.
Source: https://aws.amazon.com/blogs/devops/improve-build-performance-and-save-time-using-local-caching-in-aws-codebuild/
CodeBuild now provides a cache feature you can use to pre-load your dependencies.