services:
  web_beyhan:
    build:
      context: .
      dockerfile: ./build/Dockerfile
    container_name: web_beyhan
    command: gunicorn core.wsgi:application --bind 0.0.0.0:8000 --workers 3
    dns:
      - 8.8.8.8
      - 8.8.4.4
    volumes:
      - static_volume:/app/staticfiles
      - media_volume:/app/media
    expose:
      - 8000
    networks:
      - dokploy-network
    environment:
      - DEBUG=0
      - SECRET_KEY=${SECRET_KEY}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_HOST=${MYSQL_HOST}
      - MYSQL_PORT=${MYSQL_PORT}
      - DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
      # Celery ayarları
      - CELERY_BROKER_URL=${CELERY_BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND:-django-db}
      # Email Settings (Optional)
      - EMAIL_BACKEND=${EMAIL_BACKEND:-django.core.mail.backends.smtp.EmailBackend}
      - EMAIL_HOST=${EMAIL_HOST:-10.80.80.70}
      - EMAIL_PORT=${EMAIL_PORT:-1025}
      - EMAIL_HOST_USER=${EMAIL_HOST_USER}
      - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
      - EMAIL_USE_TLS=${EMAIL_USE_TLS:-False}
      - EMAIL_USE_SSL=${EMAIL_USE_SSL:-True}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL:-noreply@localhost}
    restart: unless-stopped

  celery_beyhan:
    build:
      context: .
      dockerfile: ./build/Dockerfile
    container_name: celery_beyhan
    command: celery -A core worker -l info
    dns:
      - 8.8.8.8
      - 8.8.4.4
    volumes:
      - media_volume:/app/media
    networks:
      - dokploy-network
    environment:
      - DEBUG=0
      - SECRET_KEY=${SECRET_KEY}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_HOST=${MYSQL_HOST}
      - MYSQL_PORT=${MYSQL_PORT}
      - DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
      - CELERY_BROKER_URL=${CELERY_BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND:-django-db}
    depends_on:
      - web_beyhan
    restart: unless-stopped

  celery_beat_beyhan:
    build:
      context: .
      dockerfile: ./build/Dockerfile
    container_name: celery_beat_beyhan
    command: celery -A core beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler --pidfile=
    dns:
      - 8.8.8.8
      - 8.8.4.4
    volumes:
      - media_volume:/app/media
    networks:
      - dokploy-network
    environment:
      - DEBUG=0
      - SECRET_KEY=${SECRET_KEY}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
      - MYSQL_HOST=${MYSQL_HOST}
      - MYSQL_PORT=${MYSQL_PORT}
      - DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
      - CELERY_BROKER_URL=${CELERY_BROKER_URL}
      - CELERY_RESULT_BACKEND=${CELERY_RESULT_BACKEND:-django-db}
      # Email Settings (Optional)
      - EMAIL_BACKEND=${EMAIL_BACKEND:-django.core.mail.backends.smtp.EmailBackend}
      - EMAIL_HOST=${EMAIL_HOST:-10.80.80.70}
      - EMAIL_PORT=${EMAIL_PORT:-1025}
      - EMAIL_HOST_USER=${EMAIL_HOST_USER}
      - EMAIL_HOST_PASSWORD=${EMAIL_HOST_PASSWORD}
      - EMAIL_USE_TLS=${EMAIL_USE_TLS:-False}
      - EMAIL_USE_SSL=${EMAIL_USE_SSL:-True}
      - DEFAULT_FROM_EMAIL=${DEFAULT_FROM_EMAIL:-noreply@localhost}
    depends_on:
      - web_beyhan
    restart: unless-stopped

  caddy_beyhan:
    build:
      context: .
      dockerfile: ./caddy/Dockerfile
    container_name: caddy_beyhan
    ports:
      - "${CADDY_HTTP_PORT:-8080}:80"
    networks:
      - dokploy-network
    volumes:
      - static_volume:/app/staticfiles:ro
      - media_volume:/app/media:ro
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      - web_beyhan
    restart: unless-stopped

volumes:
  static_volume:
  media_volume:
  caddy_data:
  caddy_config:

networks:
  dokploy-network:
    external: true
