CodeBuild Remote Code Copy

Jets creates an archive copy of your code and uploads it to s3 for deployment. Jets does it’s best use whatever is in your directory working tree, respecting the .gitignore. Additonally, you can customize the copy behavior.

config/jets/bootstrap.rb

Jets.bootstrap.configure do
  config.code.copy.strategy = "auto" # automatically decide
end

Copy Strategies

The default config.code.copy.strategy = "auto" means Jets will choose a copy strategy based on whether the project folder is a git repo and what’s installed on the system.

The Precedence:

  1. rsync: The current folder is a git repo and rsync is installed. This also requires the zip command.
  2. git_copy: The current folder is a git repo, and git is installed but rsync is not.
  3. full: Falls back to a simple full copy. IE: cp -r. This will larger zip archives.

With the rsync and git_copy strategies, Jets first copies the working tree to a temp folder to create the zip file, leaving your working directory untouched.

The rsync is faster than the git_copy because rsync uses .gitignore from the onset to only copy what’s needed.

The git_copy strategy must first copy everything to a temp folder. This can include large folders like tmp or node_modules, which take much longer. Then, it will use git archive to create the zip file. The large folders do not end up in the final zip artifact.

There is also a git_inline strategy that creates the zip file without copying it to a temp folder. It is faster, but it can add a side-effect git commit if the working directory is dirty.

The rsync strategy probably the best strategy.

If you set config.code.copy.strategy, it overrides the default auto behavior, and you can use strategies that auto does not consider.

Reference

The table below covers each setting. Each option is configured with config.OPTION. The config. portion is not shown for conciseness. IE: logger.level vs config.logger.level.

Name Default Description
code.copy.strategy auto Jets chooses a copy strategy. The preference is git_rsync. Options: auto full git_copy git_inline git_rsync
code.copy.always_keep [“config/jets/env”] Files to always copy to the archive zip regardless of .gitignore
code.copy.always_remove “tmp” Files to always delete regardless of .gitignore

See Full Config Reference