version: '3.8'

services:
  # Database Service (SQLite)
  db:
    image: keinos/alpine-sqlite:latest
    container_name: rental-mobil-db
    volumes:
      - ./db:/data
    environment:
      - SQLITE_DATABASE=prod.db

  # Application Service
  app:
    build: .
    container_name: rental-mobil-app
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=file:/data/prod.db
      - NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
      - NEXTAUTH_URL=${NEXTAUTH_URL}
    volumes:
      - ./db:/data
      - ./uploads:/app/public/uploads
    depends_on:
      - db
    restart: unless-stopped

  # Nginx Reverse Proxy (Optional)
  nginx:
    image: nginx:alpine
    container_name: rental-mobil-nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./ssl:/etc/nginx/ssl
    depends_on:
      - app
    restart: unless-stopped

volumes:
  db:
    driver: local
  uploads:
    driver: local
  ssl:
    driver: local

networks:
  default:
    driver: bridge