2

I've a Bitbucket Pipeline that is using an custom docker image as a base. Pulling it from the ECR. Also, I'm using this image to build dockerized Go apps in the first step with make commands. I want to cache Go modules that are being downloaded in the make build process. But when I read the examples, people are using Go base images to make caching work. How can I activate caching while using base image other than Go image itself? Related parts of my pipeline is on below and Go cache seems doesn't work.

image: 
name: <ECR Image>
  aws:  
    access-key: $AWS_ACCESS_KEY_ID 
    secret-key: $AWS_SECRET_ACCESS_KEY

definitions:
  caches:
  go: $GOPATH/pkg

pipelines:
 tags:
 '*-beta*'        
   -step: 
      name: "Image Build & Push" 
      services: 
        -docker 
      caches: 
        -go 
      script: 
        - export ENVIRONMENT=beta 
        - echo "Environment is ${ENVIRONMENT}" 
        - export DOCKER_IMAGE_BUILDER="${BITBUCKET_REPO_SLUG}:builder" 
        - make clean 
        - make build BUILD_VER=${BITBUCKET_TAG}.${BITBUCKET_BUILD_NUMBER} \  APP_NAME=${BITBUCKET_REPO_SLUG} \ 
            DOCKER_IMAGE_BUILDER=${DOCKER_IMAGE_BUILDER} 
        - make test
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Oguzhan Aygun
  • 1,314
  • 1
  • 10
  • 24

0 Answers0