Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 511
Duncan McGregor Avatar asked Jul 04 '17 13:07

Duncan McGregor


People also ask

Which of the following is used for caching content of AWS?

Content Delivery Network (CDN) A CDN provides you the ability to utilize its global network of edge locations to deliver a cached copy of web content such as videos, webpages, images and so on to your customers.

How do you encrypt the build artifacts that are stored by CodeBuild?

Build artifact encryption - The CodeBuild service role associated with the build project requires access to a KMS key in order to encrypt its build output artifacts. By default, CodeBuild uses an AWS managed key for Amazon S3 in your AWS account.

What is the difference between CodeBuild and CodeDeploy?

CodeBuild - A scalable service to compile, test, and package source code. CodeDeploy - A service to automate code deployments anywhere.

Where are CodeBuild artifacts stored?

zip , the output artifact is stored in MyArtifacts/<build-ID>/MyArtifact. zip . If this flag is set, a name specified in the buildspec file overrides the artifact name. The name specified in a buildspec file is calculated at build time and uses the Shell Command Language.


2 Answers

CodeBuild now provides a cache feature you can use to pre-load your dependencies.

like image 127
Unsigned Avatar answered Oct 17 '22 04:10

Unsigned


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/

like image 28
Justin Rice Avatar answered Oct 17 '22 04:10

Justin Rice