I’m new to CircleCI and I haven’t set up too many CIs in general yet.
My project is dockerized. It has a
docker-compose.yml that runs
postgres and an image that it builds from
I want my tests in CI to be run inside the docker container by using the same
docker-compose.yml. From what I’ve seen you’re building your docker environment inside the circleci config. But I don’t want to repeat myself in this file. It’s not DRY. I wish that I would bet let to just run
docker-compose up and then run my test suite. It should also cache the docker images.
Can someone guide me in the right direction?
Hi @mg98! We offer a machine executor, which would allow you to run Docker and docker-compose commands as you normally would: https://circleci.com/docs/2.0/executor-types/#using-machine. However, the images may not be cached. The best way would be to utilise the Docker executor with multiple images, which would increase the chances of the image being cached: https://circleci.com/docs/2.0/executor-types/#using-docker. While I understand the want to not repeat configuration, there can be advantages to doing so, such as fine-tuning the image used (e.g using one of our convenience images in the pipeline, and a custom image locally).
Hello @gmemstr! Thanks for the explanation. I’m confused by the phrase “increase the chances of the image being cached” That’s not how computers work, is it? Can you elaborate on that? In which circumstances would the image be cached on a machine executor for example?