version: '3.7'

services:
  web:
    depends_on:
      server:
        condition: service_healthy

  server:
    tty: true
    depends_on:
      mysqldb:
        condition: service_healthy
      cache:
        condition: service_started
    build:
      context: .
      target: test
    restart: on-failure
    env_file:
      - .env
    command: [ "bash", "-c", "./db_deploy.sh && npm run exec-tests" ]

  mysqldb:
    tty: true
    restart: on-failure
    env_file:
      - .env
    volumes:
      - mysql_test:/var/lib/mysql

  cache:
    tty: true
    restart: on-failure
    env_file:
      - .env
    volumes:
      - cache_test:/data

volumes:
  mysql_test:
    driver: local
  cache_test:
    driver: local

networks:
  my_project:
    driver: bridge
