services:
  postgres:
    image: postgres:16-alpine
    container_name: rental-postgres
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data

  api:
    build:
      context: .
      dockerfile: ./apps/api/Dockerfile
    container_name: rental-api
    restart: unless-stopped
    env_file:
      - .env
    environment:
      DATABASE_URL: postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
    depends_on:
      - postgres
    ports:
      - "${API_PORT:-4000}:4000"

  web:
    build:
      context: .
      dockerfile: ./apps/web/Dockerfile
    container_name: rental-web
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      - api
    ports:
      - "${WEB_PORT:-3000}:3000"

volumes:
  postgres-data:
