# THIS FILE IS AUTO-GENERATED BY generate_envoy_config.py
# DO NOT EDIT MANUALLY.
#
# It contains the service definitions for the camoufox instances
# and adds the necessary dependencies to the main services.
services:
{% for proxy in proxies %}
  camoufox-{{ loop.index }}:
    build:
      context: ./camoufox
      dockerfile: Dockerfile
      args:
        VNC_PASSWORD: "{{ vnc_password }}"
    shm_size: 2gb # Increase shared memory for browser stability
    volumes:
      - camoufox-data-{{ loop.index }}:/app/persistent-data
    ports:
      - "{{ base_vnc_port + loop.index - 1 }}:5900"
    networks:
      - proxynet
    command: [
      "--ws-host", "0.0.0.0",
      "--port", "12345",
      "--ws-path", "mypath",
      "--proxy-url", "{{ proxy.url }}",
      "--locale", "en-US",
      "--geoip",
      "--extensions", "/app/extensions/google_sign_in_popup_blocker-1.0.2.xpi,/app/extensions/spoof_timezone-0.3.4.xpi,/app/extensions/youtube_ad_auto_skipper-0.6.0.xpi",
      "--persistent-context",
      "--user-data-dir", "/app/persistent-data",
      "--preferences", "security.sandbox.content.level=0,layers.acceleration.disabled=true,cookiebanners.service.mode=2,cookiebanners.service.mode.privateBrowsing=2,network.cookie.lifetimePolicy=0,network.cookie.thirdparty.sessionOnly=false,network.cookie.cookieBehavior=0,network.cookie.alwaysAcceptSessionCookies=true",
      "--num-instances", "{{ num_instances | default(4) }}",
      "--monitor-resources"
    ]
    restart: unless-stopped
{% endfor %}

{% if proxies %}
  # This service is a dependency anchor. The main services depend on it,
  # and it in turn depends on all camoufox instances.
  camoufox-group:
    image: alpine:3.19
    command: ["echo", "Camoufox dependency group ready."]
    restart: "no"
    networks:
      - proxynet
    depends_on:
{% for proxy in proxies %}
      camoufox-{{ loop.index }}:
        condition: service_started
{% endfor %}
{% endif %}

volumes:
{% for proxy in proxies %}
  camoufox-data-{{ loop.index }}:
{% endfor %}
