Is there any way to cache build dependencies using AWS CodeBuild?

Viewed 6823

Between 1 and 2 minutes of my AWS CodeBuilds are spent downloading dependencies from Maven Central.

Short of building a pre-provisioned Docker container, is there any way to cache these between builds?

2 Answers

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/

Related