# ローカルでの本番同等テスト用
# Traefikなし、ポート直接公開、本番用Dockerfileを使用
# 使用: docker compose -f docker-compose.local.yml up -d

services:
  db:
    image: postgis/postgis:16-3.4
    container_name: keinasystem_db
    environment:
      POSTGRES_DB: keinasystem
      POSTGRES_USER: keinasystem
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    ports:
      - "5432:5432"
    volumes:
      - postgres_data_local:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U keinasystem -d keinasystem"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile.prod
    container_name: keinasystem_backend
    environment:
      DB_NAME: keinasystem
      DB_USER: keinasystem
      DB_PASSWORD: ${DB_PASSWORD}
      DB_HOST: db
      DB_PORT: 5432
      SECRET_KEY: ${SECRET_KEY}
      DEBUG: "False"
      ALLOWED_HOSTS: localhost,127.0.0.1
      CORS_ALLOWED_ORIGINS: http://localhost:3000
      MAIL_API_KEY: ${MAIL_API_KEY}
      FRONTEND_URL: http://localhost:3000
    ports:
      - "8000:8000"
    depends_on:
      db:
        condition: service_healthy

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.prod
      args:
        NEXT_PUBLIC_API_URL: http://localhost:8000
    container_name: keinasystem_frontend
    ports:
      - "3000:3000"
    depends_on:
      - backend

volumes:
  postgres_data_local:
