# docker-compose -f ./dbconnect/integration_test/dbconnect.yaml up --build --force-recreate --renew-anon-volumes --exit-code-from cloudflared

version: "2.3"
networks:
  test-dbconnect-network:
    driver: bridge
services:
  cloudflared:
    build:
      context: ../../
      dockerfile: dev.Dockerfile
    command: go test github.com/cloudflare/cloudflared/dbconnect/integration_test -v
    depends_on:
      postgres:
        condition: service_healthy
      mysql:
        condition: service_healthy
      mssql:
        condition: service_healthy
      clickhouse:
        condition: service_healthy
    environment:
      DBCONNECT_INTEGRATION_TEST: "true"
      POSTGRESQL_URL: postgres://postgres:secret@postgres/db?sslmode=disable
      MYSQL_URL: mysql://root:secret@mysql/db?tls=false
      MSSQL_URL: mssql://sa:secret12345!@mssql
      CLICKHOUSE_URL: clickhouse://clickhouse:9000/db
    networks:
      - test-dbconnect-network
  postgres:
    image: postgres:11.4-alpine
    environment:
      POSTGRES_DB: db
      POSTGRES_PASSWORD: secret
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]
      start_period: 3s
      interval: 1s
      timeout: 3s
      retries: 10
    networks:
      - test-dbconnect-network
  mysql:
    image: mysql:8.0
    environment:
      MYSQL_DATABASE: db
      MYSQL_ROOT_PASSWORD: secret
    healthcheck:
      test: ["CMD", "mysqladmin", "ping"]
      start_period: 3s
      interval: 1s
      timeout: 3s
      retries: 10
    networks:
      - test-dbconnect-network
  mssql:
    image: mcr.microsoft.com/mssql/server:2017-CU8-ubuntu
    environment:
      ACCEPT_EULA: "Y"
      SA_PASSWORD: secret12345!
    healthcheck:
      test: ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-S", "localhost", "-U", "sa", "-P", "secret12345!", "-Q", "SELECT 1"]
      start_period: 3s
      interval: 1s
      timeout: 3s
      retries: 10
    networks:
      - test-dbconnect-network
  clickhouse:
    image: yandex/clickhouse-server:19.11
    healthcheck:
      test: ["CMD", "clickhouse-client", "--query", "SELECT 1"]
      start_period: 3s
      interval: 1s
      timeout: 3s
      retries: 10
    networks:
      - test-dbconnect-network
