docker-compose.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. services:
  2. 3xui:
  3. build:
  4. context: .
  5. dockerfile: ./Dockerfile
  6. container_name: 3xui_app
  7. # hostname: yourhostname <- optional
  8. # Optional hard memory cap. When set, the panel derives its Go soft limit
  9. # (GOMEMLIMIT, ~90% of this cap) so it GCs before the OOM killer fires.
  10. # mem_limit: 512m
  11. # The bundled Fail2ban (XUI_ENABLE_FAIL2BAN below) enforces the IP limit
  12. # with iptables, which needs NET_ADMIN. Without these caps a ban is logged
  13. # and shown in fail2ban status but never actually applied. NET_RAW covers
  14. # ip6tables. If you disable Fail2ban, you can drop cap_add.
  15. #
  16. # AmneziaWG works in this image: it runs embedded in the panel process
  17. # (amneziawg-go over a gVisor userspace netstack), so it needs no kernel
  18. # module and no host tooling. Publish its UDP listen port to use it.
  19. cap_add:
  20. - NET_ADMIN
  21. - NET_RAW
  22. volumes:
  23. - $PWD/db/:/etc/x-ui/
  24. - $PWD/cert/:/root/cert/
  25. # Persists acme.sh state so certificate auto-renewal survives container
  26. # recreation (the entrypoint re-registers the renewal cron job from it).
  27. - $PWD/acme/:/root/.acme.sh/
  28. environment:
  29. XRAY_VMESS_AEAD_FORCED: "false"
  30. XUI_ENABLE_FAIL2BAN: "true"
  31. # Memory tuning. The panel keeps RAM low via GOGC + periodic release; it no
  32. # longer sets a soft limit from total host RAM (no benefit, risks GC thrash).
  33. # XUI_GOGC: "75" # lower = less RAM, slightly more CPU; GOGC env overrides
  34. # XUI_MEMORY_RELEASE_INTERVAL: "10" # minutes between FreeOSMemory; 0 disables
  35. # Go memory soft limit, only applied from an explicit budget below (or a
  36. # real cgroup/mem_limit cap). Pin it with one of:
  37. # XUI_MEMORY_LIMIT: "400" # in MiB
  38. # GOMEMLIMIT: "400MiB" # Go syntax, takes precedence
  39. # XUI_PPROF: "true" # expose pprof on 127.0.0.1:6060 for profiling
  40. # XUI_INIT_WEB_BASE_PATH: "/"
  41. # XUI_PORT: "8080"
  42. # To use PostgreSQL instead of the default SQLite, run:
  43. # docker compose --profile postgres up -d
  44. # and uncomment the two lines below.
  45. # XUI_DB_TYPE: "postgres"
  46. # XUI_DB_DSN: "postgres://xui:xui@postgres:5432/xui?sslmode=disable"
  47. tty: true
  48. ports:
  49. # When XUI_PORT is set, publish the same container port (for example "8080:8080").
  50. - "2053:2053"
  51. restart: unless-stopped
  52. postgres:
  53. image: postgres:16-alpine
  54. container_name: 3xui_postgres
  55. profiles: ["postgres"]
  56. environment:
  57. POSTGRES_USER: xui
  58. POSTGRES_PASSWORD: xui
  59. POSTGRES_DB: xui
  60. volumes:
  61. - $PWD/pgdata/:/var/lib/postgresql/data
  62. restart: unless-stopped