Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can circle ci use docker-compose to build the environment

I currently have a few services such as db and web in a django application, and docker-compose is used to string them together.

The web version has code like this..

web:
  restart: always
  build: ./web
  expose:
    - "8000"

The docker file in web has python2.7-onbuild, so it uses the requirements.txt file to install all the necessary dependencies.

I am now using circle CI for integration and have a circle.yml file like this..

....
dependencies:
  pre:
    -  pip install -r web/requirements.txt
....

Is there anyway I could avoid the dependency clause in the circle yml file.

Instead I would like Circle CI to use docker-compose.yml instead, if that makes sense.

like image 893
Rajesh Chamarthi Avatar asked Aug 03 '15 12:08

Rajesh Chamarthi


People also ask

Does CircleCI use Docker?

Overview. CircleCI supports Docker, providing you with a powerful way to specify dependencies for your projects. If the CircleCI convenience images do not suit your needs, consider creating a custom Docker image for your jobs.

Does Docker build use Docker compose?

The Dockerfile uses the docker build command, while the docker-compose. yaml file uses the docker-compose up command. A docker-compose. yaml file can reference a Dockerfile, but a Dockerfile can't reference a docker-compose file.


1 Answers

Yes, using docker-compose in the circle.yml file can be a nice way to run tests because it can mirror ones dev environment very closely. This is a extract from our working tests on a AngularJS project:

---

machine:
  services:
    - docker

dependencies:
  override:
    - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
    - sudo pip install --upgrade docker-compose==1.3.0

test:
  pre:
    - docker-compose pull
    - docker-compose up -d
    - docker-compose run npm install
    - docker-compose run bower install --allow-root --config.interactive=false
  override:
    # grunt runs our karma tests
    - docker-compose run grunt deploy-build compile

Notes:

  • The docker login is only needed if you have private images in docker hub.
  • when we wrote our circle.yml file only docker-compose 1.3 was available. This is probably updated now.
like image 97
Tom Avatar answered Sep 24 '22 13:09

Tom