[PR #5240] [MERGED] feat(docker): support XUI_PORT runtime override #5824

Closed
opened 2026-11-02 04:04:21 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5240
Author: @surfdps
Created: 6/12/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @MHSanaei

Base: main ← Head: feat/xui-port-docker-override


📝 Commits (3)

  • 888beb3 feat(docker): support XUI_PORT runtime override
  • 5a545ef docs: describe XUI_PORT deployment usage
  • 67d0fde Merge branch 'main' into feat/xui-port-docker-override

📊 Changes

6 files changed (+99 additions, -1 deletions)

View changed files

📝 .env.example (+1 -0)
📝 CONTRIBUTING.md (+8 -0)
📝 docker-compose.yml (+3 -1)
📝 internal/config/config.go (+18 -0)
➕ internal/config/config_test.go (+61 -0)
📝 internal/web/web.go (+8 -0)

📄 Description

Summary

Adds an optional XUI_PORT environment variable that overrides the web panel's database-backed port at runtime without modifying the persisted setting. It also documents local and Docker Compose usage.

Why

Container deployments currently require mutating the database to change the panel's internal listening port. This enables configuring it through Docker, Compose, systemd, or other deployment environments.

Closes #4846

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • Added table-driven unit tests covering unset, empty, whitespace, valid, malformed, and out-of-range values.
  • Ran go test ./....
  • Ran go build ./....
  • Built the Docker image successfully.
  • Verified XUI_PORT=38080 changes the listener while persisted webPort remains 2053.
  • Verified restarting without XUI_PORT restores port 2053.
  • Verified an invalid value falls back to port 2053 and logs a warning.
  • Validated the Compose configuration with docker compose config --quiet.

Screenshots / recordings

None.

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5240 **Author:** [@surfdps](https://github.com/surfdps) **Created:** 6/12/2026 **Status:** ✅ Merged **Merged:** 6/14/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `feat/xui-port-docker-override` --- ### 📝 Commits (3) - [`888beb3`](https://github.com/MHSanaei/3x-ui/commit/888beb3a82a7aa7ee3f685ab1c040d96150cf0a1) feat(docker): support XUI_PORT runtime override - [`5a545ef`](https://github.com/MHSanaei/3x-ui/commit/5a545ef5728ae09e5d18361a95054c185a85a285) docs: describe XUI_PORT deployment usage - [`67d0fde`](https://github.com/MHSanaei/3x-ui/commit/67d0fdea24ad0138e111453a23533496387cfa33) Merge branch 'main' into feat/xui-port-docker-override ### 📊 Changes **6 files changed** (+99 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+1 -0) 📝 `CONTRIBUTING.md` (+8 -0) 📝 `docker-compose.yml` (+3 -1) 📝 `internal/config/config.go` (+18 -0) ➕ `internal/config/config_test.go` (+61 -0) 📝 `internal/web/web.go` (+8 -0) </details> ### 📄 Description ## Summary Adds an optional `XUI_PORT` environment variable that overrides the web panel's database-backed port at runtime without modifying the persisted setting. It also documents local and Docker Compose usage. ## Why Container deployments currently require mutating the database to change the panel's internal listening port. This enables configuring it through Docker, Compose, systemd, or other deployment environments. Closes #4846 ## Type of change - [ ] Bug fix - [x] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [x] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [x] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - Added table-driven unit tests covering unset, empty, whitespace, valid, malformed, and out-of-range values. - Ran `go test ./...`. - Ran `go build ./...`. - Built the Docker image successfully. - Verified `XUI_PORT=38080` changes the listener while persisted `webPort` remains `2053`. - Verified restarting without `XUI_PORT` restores port `2053`. - Verified an invalid value falls back to port `2053` and logs a warning. - Validated the Compose configuration with `docker compose config --quiet`. ## Screenshots / recordings None. ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [x] `go build ./...` and the test suite pass locally. - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [x] I updated the Wiki / README / API docs if user-facing behavior changed. - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:21 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5824
No description provided.