# ============================================================================
# Cara termudah menjalankan di server (VPS Rumahweb / lokal):
#   1) Ganti JWT_SECRET di bawah dengan string acak panjang.
#   2) docker compose up -d --build
#   3) (sekali saja) isi data awal:  docker compose exec app npx prisma db seed
#   Aplikasi jalan di http://SERVER:3000
# ============================================================================

services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      # --- SQLite (bawaan). File DB disimpan di volume "telur-db" (/data) ---
      DATABASE_URL: "file:/data/prod.db"
      # WAJIB diganti untuk produksi (mis. hasil `openssl rand -base64 48`):
      JWT_SECRET: "GANTI-DENGAN-STRING-ACAK-PANJANG"
      NODE_ENV: "production"
      ACCESS_TOKEN_TTL_MIN: "15"
      REFRESH_TOKEN_TTL_DAYS: "1"
      STORAGE_DRIVER: "local"
      # --- Opsi PostgreSQL: hapus komentar service "db" di bawah lalu ganti:
      # DATABASE_URL: "postgresql://postgres:pass@db:5432/telur?schema=public"
    volumes:
      - telur-db:/data                       # database SQLite persisten
      - telur-uploads:/app/public/uploads    # foto bukti kurir persisten
    restart: unless-stopped
    # depends_on: [db]   # aktifkan bila pakai PostgreSQL

  # --- PostgreSQL (opsional). Hapus komentar seluruh blok untuk memakainya. ---
  # db:
  #   image: postgres:16
  #   environment:
  #     POSTGRES_PASSWORD: pass
  #     POSTGRES_DB: telur
  #   volumes:
  #     - pgdata:/var/lib/postgresql/data
  #   restart: unless-stopped

volumes:
  telur-db:
  telur-uploads:
  # pgdata:
