version: '3'

services:

  dev:
    build: .
    volumes:
      - .:/app
    ports:
      - "3000:3000"
    env_file:
      - test.env
    command: "tail -f /dev/null"
    depends_on:
      - setup_dev

  setup_dev:
    build: .
    volumes:
      - .:/app
    env_file:
      - test.env
    command: >
      bash -c "sleep 5; rake db:setup
      && rake environment elasticsearch:import:model CLASS='Room' FORCE=true
      && rake environment elasticsearch:import:model CLASS='Reservation' FORCE=true"
    depends_on:
      - db

  test:
    # build: .
    image: nyulibraries/rooms:dev
    environment:
      RAILS_ENV: test
      ROOMS_DB_DATABASE: rooms_test
    env_file:
      - test.env
    command: "tail -f /dev/null"
    depends_on:
      - setup_test

  setup_test:
    # build: .
    image: nyulibraries/rooms:dev
    environment:
      RAILS_ENV: test
      ROOMS_DB_DATABASE: rooms_test
    env_file:
      - test.env
    command: bash -c "sleep 5; rake db:setup"
    depends_on:
      - db

  db:
    image: library/mysql:5.6.22
    expose:
      - "3306"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    depends_on:
      - elasticsearch

  elasticsearch:
    image: elasticsearch:2.4.3
    ports:
      - "9200:9200"

version: '3'

services:

  dev:
    build: .
    volumes:
      - .:/app
    ports:
      - "3000:3000"
    env_file:
      - test.env
    command: "tail -f /dev/null"
    depends_on:
      - setup_dev

  setup_dev:
    build: .
    volumes:
      - .:/app
    env_file:
      - test.env
    command: >
      bash -c "sleep 5; rake db:setup
      && rake environment elasticsearch:import:model CLASS='Room' FORCE=true
      && rake environment elasticsearch:import:model CLASS='Reservation' FORCE=true"
    depends_on:
      - db

  test:
    build: .
    environment:
      RAILS_ENV: test
      ROOMS_DB_DATABASE: rooms_test
    env_file:
      - test.env
    command: "tail -f /dev/null"
    depends_on:
      - setup_test

  setup_test:
    build: .
    environment:
      RAILS_ENV: test
      ROOMS_DB_DATABASE: rooms_test
    env_file:
      - test.env
    command: bash -c "sleep 5; rake db:setup"
    depends_on:
      - db

  db:
    image: library/mysql:5.6.22
    expose:
      - "3306"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    depends_on:
      - elasticsearch

  elasticsearch:
    image: elasticsearch:2.4.3
    ports:
      - "9200:9200"

Build and test against docker image in circleci, not pre-pushed to container repos
Build and test against docker image in circleci, not pre-pushed to container repos
