Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Basic question about sharing docker instances

Lucas Vazquez
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!
September 28, 2022

Hello everyone!

Today I discovered bitbucket pipelines and I find it very interesting.

But I have a basic performance problem, probably very common.

I have a script that looks like the following code:

image: docker/compose:1.29.2

pipelines:
default:
- step:
name: Setup
script:
- cp .env.local .env
- docker-compose up -d
- echo Setup done
services:
- docker
- step:
name: Run migrations
script:
- docker-compose run project alembic upgrade head
- echo Migrations done
services:
- docker
- step:
name: Run tests
script:
- docker-compose run project python -m pytest -rP -vv -x
- echo Tests done
services:
- docker

What is the problem? The second step returns Error: No such container
I realized I need to setup the container for each step, but there is any way to do this?

This is a good way to implement what I want??

image: docker/compose:1.29.2

pipelines:
default:
- step:
name: Run migrations
script:
- cp .env.local .env
- docker-compose up -d
- docker-compose run project alembic upgrade head
- echo Migrations done
services:
- docker
- step:
name: Run tests
script:
- cp .env.local .env
- docker-compose up -d
- docker-compose run project python -m pytest -rP -vv -x
- echo Tests done
services:
- docker

Just for context: the docker compose has a mysql, a firestore emulator, and an image that installs certain python packages.

2 answers

1 accepted

0 votes
Answer accepted
Aron Gombas _Midori_
Community Champion
September 29, 2022

Bitbucket Pipelines has a feature called cache which allows one step to produce an artifact which can used by later steps:

https://support.atlassian.com/bitbucket-cloud/docs/cache-dependencies/

Lucas Vazquez
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!
October 31, 2022

Thanks! This is what I was looking for

Like Aron Gombas _Midori_ likes this
0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 29, 2022

You should consider that each step runs on a different container, possibly on different host.

The simplest option would be to upload the created image (in step #1) to a repository and pull it / use it as a runner in the next step.  

Suggest an answer

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

Atlassian Community Events