docker-compose.yml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. services:
  2. bambuddy:
  3. image: ghcr.io/maziggy/bambuddy:latest
  4. build: .
  5. # Usage:
  6. # docker compose up -d → pulls pre-built image from ghcr.io
  7. # docker compose up -d --build → builds locally from source
  8. container_name: bambuddy
  9. # File ownership inside the data and logs volumes is normalised by the
  10. # entrypoint at startup (chowns to PUID:PGID and drops privileges via
  11. # gosu before running the app). Override PUID / PGID below to match
  12. # your host user if needed — defaults to 1000:1000 to match the
  13. # historical compose `user:` directive.
  14. #
  15. # Allow binding to privileged ports (322, 990) as non-root user — required
  16. # for FTPS in every VP mode and for the RTSPS camera proxy in proxy mode +
  17. # non-proxy modes that have a target printer configured. Without this, the
  18. # FTP and RTSP listeners silently fail.
  19. cap_add:
  20. - NET_BIND_SERVICE
  21. #
  22. # LINUX: Use host mode for printer discovery and camera streaming
  23. network_mode: host
  24. #
  25. # macOS/WINDOWS: Docker Desktop doesn't support host mode.
  26. # Comment out "network_mode: host" above and uncomment "ports:" below.
  27. # Note: Printer discovery won't work - add printers manually by IP.
  28. #ports:
  29. # - "${PORT:-8000}:8000"
  30. # - "3000:3000" # Virtual printer bind/detect
  31. # - "3002:3002" # Virtual printer bind/detect
  32. # - "8883:8883" # Virtual printer MQTT
  33. # - "990:990" # Virtual printer FTP control
  34. # - "6000:6000" # Virtual printer file transfer tunnel
  35. # - "322:322" # Virtual printer RTSP camera (X1/H2/P2; proxy mode + non-proxy modes with a target printer)
  36. # - "2024-2026:2024-2026" # Virtual printer proprietary ports (A1/P1S)
  37. # - "50000-50029:50000-50029" # Virtual printer FTP passive data (3 VPs × 10-port slice)
  38. #
  39. # FTP passive-mode port slicing (#1646): non-proxy VPs (Archive / Review /
  40. # Queue modes) get a 10-port slice each, allocated by VP id — VP 1 →
  41. # 50000-50009, VP 2 → 50010-50019, VP 3 → 50020-50029, etc. The default
  42. # exposure above covers 3 VPs; widen the range to cover more
  43. # (`50000-500N9` where N = vp_count - 1). Proxy-mode VPs forward the
  44. # real printer's full 50000-50100 range — if you use proxy mode, expose
  45. # `50000-50100:50000-50100` instead.
  46. #
  47. # Why narrow this matters on bridge mode: with Docker's default
  48. # userland-proxy (true), every exposed port spawns one docker-proxy host
  49. # process per address family (IPv4 + IPv6). The original 1001-port range
  50. # spawned ~2000 such processes, pinning ~3.5 GB of host RAM that doesn't
  51. # appear in `docker stats` (host-level, not container-level). 30 ports
  52. # → ~60 processes → ~210 MB instead.
  53. #
  54. # Bridge mode is the normal setup for any Linux host that runs
  55. # Bambuddy alongside other services (NAS, multi-tenant Docker VM,
  56. # Synology DSM, Unraid) — `network_mode: host` would conflict with
  57. # ports those other services already bind. Bambuddy uses host mode by
  58. # default because SSDP printer discovery needs L2 multicast, but it's
  59. # a deliberate trade-off, not a security-blind default; setups that
  60. # forgo discovery (add printers by IP) can stay on bridge with the
  61. # narrowed range above.
  62. volumes:
  63. - bambuddy_data:/app/data
  64. - bambuddy_logs:/app/logs
  65. #
  66. # OPTIONAL — only needed if you ALSO run a native install of Bambuddy
  67. # on the same host and want both installs to share the same Virtual
  68. # Printer CA certificate (so the slicer only has to trust one CA).
  69. # Most Docker-only users should leave this commented out — the
  70. # entrypoint will keep the VP data inside the named volume above.
  71. # If uncommented, the entrypoint chowns the host directory to
  72. # PUID:PGID on first start so the container user can write to it.
  73. #- ./virtual_printer:/app/data/virtual_printer
  74. #
  75. # Mount scheduled backup output to NAS or external storage
  76. # Backups default to DATA_DIR/backups/ inside the data volume.
  77. # Uncomment to store them externally (e.g. on a NAS share).
  78. #- /path/to/nas/bambuddy-backups:/app/data/backups
  79. #
  80. # Tailscale integration (optional): mount the host's tailscaled socket
  81. # so Bambuddy can request Let's Encrypt certs for virtual printers via
  82. # your tailnet's MagicDNS name. Requires:
  83. # 1. Tailscale installed + `tailscale up` completed on the host
  84. # 2. `sudo tailscale set --operator=<container-user>` on the host so
  85. # the user running the container can call `tailscale cert`
  86. # Without this mount, the Tailscale toggle in the UI is harmless —
  87. # Bambuddy falls back to self-signed certs.
  88. #- /var/run/tailscale/tailscaled.sock:/var/run/tailscale/tailscaled.sock
  89. #
  90. # Using a self signed certificate for Home Assistant
  91. # Add your certificate to certs directory and mount it to the container.
  92. # The certificate will be added to the system trust store on container startup.
  93. # Enable the system trust store with the USE_SYSTEM_TRUST_STORE env var to
  94. # have Bambuddy trust the certificate.
  95. # - /path/to/certs:/usr/local/share/ca-certificates
  96. #
  97. # External library folders. Mount the host paths the operator wants
  98. # users to be able to register as external folders. The in-container
  99. # paths chosen here MUST appear in BAMBUDDY_EXTERNAL_ROOTS below.
  100. # Read-only (:ro) is recommended unless you want users uploading
  101. # files back to the host share.
  102. #- /mnt/nas/3d-prints:/external/nas:ro
  103. #- /srv/library:/external/projects:ro
  104. environment:
  105. - TZ=${TZ:-Europe/Berlin}
  106. # User/group the container drops to after the entrypoint normalises
  107. # ownership on /app/data and /app/logs. Match your host user (run
  108. # `id -u` / `id -g`) if you want files written by the container to
  109. # show up as your user on the host. Defaults to 1000:1000.
  110. - PUID=${PUID:-1000}
  111. - PGID=${PGID:-1000}
  112. # Port BamBuddy runs on (default: 8000)
  113. # Usage: PORT=8080 docker compose up -d
  114. - PORT=${PORT:-8000}
  115. # Directory this compose file lives in, so Settings → Updates can print
  116. # an update command you can paste from anywhere instead of one that only
  117. # works if you are already in the right directory (#2664). Uncomment to
  118. # have Compose fill it in from the shell you run `docker compose` in; the
  119. # field is also editable in Settings if you would rather set it there or
  120. # if you drive Compose with `-f` from elsewhere.
  121. #- BAMBUDDY_COMPOSE_DIR=${PWD}
  122. # Virtual printer: Set to the Docker host's IP when using bridge mode (ports:).
  123. # Required for FTP passive mode to work behind NAT.
  124. # Example: VIRTUAL_PRINTER_PASV_ADDRESS=192.168.1.100
  125. #- VIRTUAL_PRINTER_PASV_ADDRESS=
  126. #
  127. # External PostgreSQL (optional — uses SQLite by default)
  128. # Example: DATABASE_URL=postgresql+asyncpg://bambuddy:password@db-host:5432/bambuddy
  129. #- DATABASE_URL=
  130. #
  131. # Slicer API sidecar (optional — Settings → "Use Slicer API" toggles this on).
  132. # Default points at the OrcaSlicer sidecar on the docker host; change if you
  133. # run the sidecar on a different host/port. The matching docker-compose.yml
  134. # for the sidecars lives in the orca-slicer-api fork
  135. # (https://github.com/maziggy/orca-slicer-api).
  136. #- SLICER_API_URL=http://localhost:3003
  137. #
  138. # MFA at-rest encryption key (#1219). Auto-generated to
  139. # DATA_DIR/.mfa_encryption_key on first startup if unset. Override here
  140. # to manage the key out-of-band (e.g. via a secret manager).
  141. #- MFA_ENCRYPTION_KEY=
  142. #
  143. # External library folders (GHSA-r2qv follow-up). Empty default
  144. # disables the "Add external folder" feature; set to one or more
  145. # colon-separated absolute paths INSIDE THE CONTAINER to opt in.
  146. # The paths must also be bind-mounted from the host — uncomment
  147. # the matching volume snippet below.
  148. # Example for a single NAS mount:
  149. #- BAMBUDDY_EXTERNAL_ROOTS=/external/nas
  150. # Example for two roots:
  151. #- BAMBUDDY_EXTERNAL_ROOTS=/external/nas:/external/projects
  152. #
  153. # Enable System Trust Store for certificate validation (e.g. for local Home Assistant)
  154. # You also need to mount your certificates to the container (see volumes section above).
  155. # - USE_SYSTEM_TRUST_STORE=true
  156. restart: unless-stopped
  157. # Docker's default is 10s, after which it SIGKILLs. Bambuddy shuts down in
  158. # well under that (uvicorn caps its wait on in-flight requests at 5s, then
  159. # the app checkpoints the SQLite WAL, disconnects MQTT and stops the virtual
  160. # printers), but a Pi with several virtual printers and a slow SD card can be
  161. # nearer the limit than is comfortable. The headroom costs nothing — the
  162. # container exits as soon as it is done, not when the timer expires.
  163. stop_grace_period: 30s
  164. # Optional: External PostgreSQL database
  165. # Uncomment to run Postgres alongside Bambuddy (or use an external Postgres host)
  166. #postgres:
  167. # image: postgres:16-alpine
  168. # container_name: bambuddy-db
  169. # restart: unless-stopped
  170. # environment:
  171. # POSTGRES_USER: bambuddy
  172. # POSTGRES_PASSWORD: changeme
  173. # POSTGRES_DB: bambuddy
  174. # volumes:
  175. # - bambuddy_pgdata:/var/lib/postgresql/data
  176. # ports:
  177. # - "5432:5432"
  178. volumes:
  179. bambuddy_data:
  180. bambuddy_logs:
  181. #bambuddy_pgdata: