version: '3.8'

services:
  consent-service:
    build: .
    ports:
      - "8081:8081"
    env_file:
      - .env
    environment:
      - DATABASE_URL=postgres://consent:consent123@postgres:5432/consent_db?sslmode=disable
    depends_on:
      postgres:
        condition: service_healthy
    networks:
      - consent-network

  postgres:
    image: postgres:16-alpine
    ports:
      - "5433:5432"
    environment:
      - POSTGRES_USER=consent
      - POSTGRES_PASSWORD=consent123
      - POSTGRES_DB=consent_db
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U consent -d consent_db"]
      interval: 5s
      timeout: 5s
      retries: 5
    networks:
      - consent-network

volumes:
  postgres_data:

networks:
  consent-network:
    driver: bridge
