Codebuild caching not making differences in build times

0

The codebuild cache on both local and s3 buckets is not working. I have specified all the steps in the build_spec.yml file along with all the dependencies. The cache file is stored in an s3 bucket but does not work when a new build happens after that.

Hema
asked 7 months ago301 views
1 Answer
0

Hi. Can you share a buildspec with us?

profile picture
answered 7 months ago
  • Hi, this is my build_spec file. version: 0.2 phases: install: commands: - echo Build and Deployment for $env environment - curl -sS -o aws-iam-authenticator https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator - export PATH=$PWD/:$PATH - yum -y update --skip-broke && yum -y install jq python3-pip python3-dev && pip3 install --upgrade awscli

    pre_build: commands: - echo Logging in to Amazon ECR... - echo bn-api_$env_$CODEBUILD_BUILD_NUMBER - aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com - IMAGE_TAG=bn_api_v$CODEBUILD_BUILD_NUMBER-$env build: commands: - echo Build started on date - echo Building the Docker image...
    - docker build --build-arg API_ENV=$env --build-arg AWS_ACCOUNT_ID=$AWS_ACCOUNT_ID --build-arg IMAGE_REPO_NAME=$BASE_IMAGE_REPO_NAME -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG post_build: commands: - echo Build completed on date - echo Pushing the Docker image... - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG artifacts: files: build.json cache: paths: - /root/.cache/pip - /usr/bin/share

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions