version: '3.8'

services:
  # Backend for testing
  backend:
    build: 
      context: ../../backend
      dockerfile: Dockerfile
    container_name: myp-backend-test
    ports:
      - "5000:5000"
    environment:
      - SECRET_KEY=testsecretkey123456789
      - DATABASE_URL=sqlite:///myp.db
      - FLASK_ENV=development
      - TESTING=true
    volumes:
      - backend-test-data:/app/instance
    networks:
      - test-network

  # Frontend for testing - bound to loopback address
  frontend-test:
    build:
      context: ..
      dockerfile: Dockerfile
    container_name: myp-frontend-test
    environment:
      - NODE_ENV=development
      - AUTH_TRUST_HOST=true
      - AUTH_SECRET=test-secret-key-for-testing-only-do-not-use-in-production
      - NEXT_PUBLIC_BACKEND_URL=http://backend:5000
    ports:
      - "127.0.0.1:3000:3000"
    depends_on:
      - backend
    networks:
      - test-network

networks:
  test-network:
    driver: bridge

volumes:
  backend-test-data: