services:
  db:
    build:
      context: ./infra/postgres
    image: rail-game-postgres
    environment:
      POSTGRES_USER: railgame
      POSTGRES_PASSWORD: railgame
      POSTGRES_DB: railgame_dev
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"

  backend:
    build:
      context: .
      dockerfile: backend/Dockerfile
    environment:
      DATABASE_URL: postgresql+psycopg://railgame:railgame@db:5432/railgame_dev
      TEST_DATABASE_URL: postgresql+psycopg://railgame:railgame@db:5432/railgame_test
      REDIS_URL: redis://redis:6379/0
      INIT_DEMO_DB: "true"
    depends_on:
      - db
      - redis
    ports:
      - "8000:8000"

  frontend:
    build:
      context: ./frontend
    depends_on:
      - backend
    ports:
      - "8080:80"

volumes:
  postgres-data:
