version: "3.9"
services:
  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    profiles: ["local-db"]
    environment:
      POSTGRES_DB: chegoou
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    ports:
      - "6379:6379"

  api:
    build:
      context: .
      dockerfile: apps/api/Dockerfile
    env_file:
      - .env
    depends_on:
      - redis
    ports:
      - "3001:3001"

  web-admin:
    build:
      context: .
      dockerfile: apps/web-admin/Dockerfile
    env_file:
      - .env
    depends_on:
      - api
    ports:
      - "3002:3000"

  web-restaurant:
    build:
      context: .
      dockerfile: apps/web-restaurant/Dockerfile
    env_file:
      - .env
    depends_on:
      - api
    ports:
      - "3003:3000"

  nginx:
    image: nginx:1.27-alpine
    depends_on:
      - api
      - web-admin
      - web-restaurant
    ports:
      - "80:80"
    volumes:
      - ./infra/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro

volumes:
  postgres_data:
