mysterious-family-43099
04/28/2023, 3:40 PMcacheFrom
option is the solve: https://www.pulumi.com/blog/build-images-50x-faster-docker-v4/
What I don't fully understand is the behavior. If I just set cacheFrom
to true
is this sufficient if all my images are tagged with latest
? Will this only pull the cached image if nothing has changed? Or will this know to pull the last image and start from the latest layer that invalidates the cache?true
and this configuration:
if (dockerArgs) {
// Need this for caching to work properly
dockerArgs.BUILDKIT_INLINE_CACHE = "1";
}
else {
dockerArgs = {}
}
// Build and push the image to ECR.
// TODO: Docker images get built and pushed every time if things haven't changed.
// This is a bug: <https://github.com/pulumi/pulumi-docker/issues/132>
// See if we can fix this by using git hashes.
const image = repo.buildAndPushImage({
context: `../../../${project}`,
...(dockerfileName && {
dockerfile: `../../../${project}/${dockerfileName}`,
}),
...(dockerArgs && {args: dockerArgs}),
args: dockerArgs,
env: {
DOCKER_BUILDKIT: '1',
},
// We need this to build images on M1 architecture.
extraOptions: ['--platform=linux/amd64', '--quiet'],
extraOptions: ['--platform=linux/amd64', '--quiet', '--load'],
// Support docker layer caching by pulling the latest image
cacheFrom: { stages: ['pre-deps', 'deps', 'build']},
target: 'final'
});