version: '3.8'

services:
  test-db:
    image: postgres:13
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: support_test
    ports:
      - "5433:5432"  # Используем другой порт, чтобы не конфликтовать с основной БД
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  test-redis:
    image: redis:alpine
    ports:
      - "6380:6379"  # Используем другой порт, чтобы не конфликтовать с основным Redis
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend-tests:
    build:
      context: ./backend
      dockerfile: Dockerfile.test
    environment:
      DATABASE_URL: postgresql://postgres:postgres@test-db:5432/support_test
      REDIS_URL: redis://test-redis:6379/0
    depends_on:
      test-db:
        condition: service_healthy
      test-redis:
        condition: service_healthy
    volumes:
      - ./backend:/app
      - ./test-results:/app/test-results 