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.

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.

I haven't tried this myself but based on the info here https://circleci.com/docs/docker I guess it may work

# circle.yml
machine:
  services:
    - docker

dependencies:
  pre:
    - pip install docker-compose

test:
  pre:
    - docker-compose up -d

Unfortunately, circleCI by default install old version of Docker 1.9.1 which is not compatible with latest version of docker-compose. In order to get more fresh docker version 1.10.0 you should:

machine:
  pre:
    - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
    - pip install docker-compose
  services:
    - docker
test:
  pre:
    - docker-compose up -d

Read more: https://discuss.circleci.com/t/docker-1-10-0-is-available-beta/2100

UPD: Native-Docker support on Circle version 2.

Read more information how to switch to new Circle CI version here: https://circleci.com/docs/2.0/migrating-from-1-2/


Need Your Help

Submit button in form doesn't work with Iscroll

javascript iscroll

i use Iscroll 5, everything is working as i want except one thing.