Running application with docker-compose for testing

Hi guys!

I’ve started exploring CircleCI 2.0 and would like to use it to start my PHP/Mysql/Elasticsearch application and run some unit and acceptance tests against it.

Now with quite some hassle I’ve gotten it to up the containers using docker-compose and remote docker, but now I’m not sure how to actually reach it. Since it’s not running on, how can I access the web- and mysql server? Maybe I’m going at this completely wrong and maybe what I want isn’t even possible, but I’ve gotten this far and now I would really like to get this to work.

Essentially my two questions are:

  • What IP will the dockerized webserver be running on?
  • Is there a better way to achieve what the result I’m looking for? My config seems… inefficient.

Here is my CircleCI config:

version: 2
      - image: php:latest
    working_directory: ~/application-name
      - checkout
      - setup_remote_docker
      - run:
          name: Update packages
          command: apt-get update
      - run:
          name: Install basic Unix tools
          command: apt-get install bzip2 -y
      - run:
          name: Install docker-compose
          command: |
            set -x
            curl -L`uname -s`-`uname -m` > /usr/local/bin/docker-compose
            chmod +x /usr/local/bin/docker-compose
      - run:
          name: Install necessary tools
          command: apt-get install git zip unzip mysql-client -y
      - run:
          name: Install Composer
          command: curl -sS | php -- --install-dir=/usr/local/bin --filename=composer
      - run:
          name: Install NodeJS / NPM
          command: |
            curl -sL | bash
            apt-get install -y nodejs
      - run:
          name: Install PHP dependencies
          command: composer install
      - run:
          name: Install Javascript dependencies
          command: npm install
      - run:
          name: Add application hostname to hosts file
          command: echo | tee -a /etc/hosts
      - run:
          name: Create application environment
          command: docker-compose up -d
      - run:
          name: TO BE REMOVED Create database
          command: mysql -h127.0.0.1 -uroot < ./build/mysql/001_create_database.sql
      - run:
          name: Provision with test data
          command: ./node_modules/.bin/gulp provision:mysql
      - run:
          name: Run acceptance tests
          command: ./node_modules/.bin/gulp test:acceptance
1 Like