ecs-conex
ecs-conex copied to clipboard
Use cached layers if repository has a yarn lockfile
Right now, images are built with the --no-cache
flag. Using cached layers is a way to significantly decrease build times, and long build times are one of the biggest bummers about our current CI flow.
One of the arguments pro --no-cache
is that without it, npm install
with semver version identifiers in package.json could lead to images that use old cached layers for node.js dependencies. This could lead to unexpected (and very non-deterministic) mismatches between your local environment and your production environment.
Yarn's use of a lockfile that pins node.js dependency versions and is committed in the repo avoids this misstep, and makes me wonder if we could drop the --no-cache
flag if there's yarn file in the repo.
However there are still a few other questions to weigh against such a decision:
-
You would only get build-time caching benefits sometimes and not all the time. This depends on whether your conex worker task lands on an EC2 that still has the cached layers from a previous build.
-
Due to ^^, you'd may want to try and keep cached layers laying around on the EC2s for longer, and this leads to disk space management problems.
It may be worth exploring this anyways, without adjusting anything about how we have our EC2s clean up old images/layers. If we can demonstrate a significant benefit for projects with hefty node.js dependency trees or huge unix package dependencies, it may be worthwhile.
cc @springmeyer @scothis @mcwhittemore @mapsam @GretaCB