1 Answer
- Newest
- Most votes
- Most comments
0
Hi,
Local CodeBuild cache is best effort and can be erased between builds.
What people usually do to circumvent local cache issue is to build a cache layer in ECR
See https://github.com/aws/aws-codebuild-docker-images/issues/26#issuecomment-370177343
version: 0.2
phases:
pre_build:
commands:
- docker version
- $(aws ecr get-login --no-include-email)
- docker pull $CONTAINER_REPOSITORY_URL:$REF_NAME || true
build:
commands:
- docker build --cache-from $CONTAINER_REPOSITORY_URL:$REF_NAME --tag $CONTAINER_REPOSITORY_URL:$REF_NAME --tag $CONTAINER_REPOSITORY_URL:ref-$CODEBUILD_RESOLVED_SOURCE_VERSION .
post_build:
commands:
- docker push $CONTAINER_REPOSITORY_URL
Re. docker build --cache-from
, see https://docs.docker.com/build/cache/
Best,
Didier
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
Thanks a lot! This works for me.