Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,567
Community Members
 
Community Events
184
Community Groups

Unable to cache composer while running a docker instance

Naveed Zahoor
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 18, 2023

I have setup custom composer cache and its working fine and it looks something like this.


definitions:
services:
docker:
memory: 3072
caches:
sonar: ~/.sonar/cache
composer-custom: /composer/cache


and my build step looks something like this 

- step: &build-api-docker-test-image
name: Build API docker test image
services:
- docker
caches:
- composer-custom
- docker
script:
- export DOCKER_BUILDKIT=1
- export IMAGE_TAG=$BITBUCKET_COMMIT
- export API_IMAGE_NAME=$API_DOCKER_IMAGE_NAME:latest
- docker build --file .docker/test/Dockerfile -t $API_IMAGE_NAME --build-arg BITBUCKET_KEY=${BITBUCKET_USERNAME} --build-arg BITBUCKET_SECRET=${BITBUCKET_READ_ACCESS_SECRET} .
- docker save --output tmp-api-image.test.docker $API_DOCKER_IMAGE_NAME
artifacts:
- tmp-api-image.test.docker


now when i try and run pipeline composer custom is always not found. because my composer install is creating files in my container. I am unable to use mount either due to restrictions. 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 19, 2023

Hello Naveed,

Thank you for reaching out to Atlassian Community!

As you mentioned, since you are doing the composer install inside your docker build command, the composer dependencies are being downloaded to a layer of docker build, and not to the pipelines build container, so this is the reason why the custom cache is not finding the composer files in the path 

~/.sonar/cache

If you were downloading the dependencies outside of the docker build, the cache should work as usual.

That said, I see you have also configured the cache for docker. This should cache the docker layers (a layer is generated for every command in the Dockerfile) that have not changed since the last build, so the layers where you are installing the composer dependencies in your docker build should be cached as part of the docker cache.

Hope that helps!

Thank you, @Naveed Zahoor !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events