services: rmbg: build: . image: rmbg-as-a-service:latest container_name: rmbg-as-a-service ports: - "${PORT:-8000}:8000" environment: - NVIDIA_VISIBLE_DEVICES=all - NVIDIA_DRIVER_CAPABILITIES=compute,utility # Default variant/resolution; both are also selectable per request. - BIREFNET_MODEL=${BIREFNET_MODEL:-general} - BIREFNET_RESOLUTION=${BIREFNET_RESOLUTION:-1024} # Use the nvidia-container-runtime for GPU acceleration. runtime: nvidia volumes: # Persist downloaded BiRefNet weights across container restarts. - hf-cache:/app/hf_cache healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"] interval: 15s timeout: 5s retries: 30 start_period: 180s restart: unless-stopped volumes: hf-cache: