refactor: clarify fixed container port with containerAppPort constant

The container always listens on 8080 internally while the user-provided
port is only the host-side mapping. Make this explicit without changing
behavior or the generated config:

- add a named containerAppPort constant and use it in both the docker -p
  mapping and the config.toml generation (was a bare 8080 literal in two
  places)
- document why config.toml hardcodes the port, so it isn't "fixed" back
  to the form value
- relabel the form field to "Porta (host)"

The generated config.toml is byte-identical (port = 8080).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
jb
2026-06-19 12:00:54 -03:00
co-authored by Claude Opus 4.8
parent 6becd3462d
commit d2717de47a
4 changed files with 12 additions and 5 deletions
+3 -2
View File
@@ -18,8 +18,9 @@ instalador, seus valores são usados como **padrão** nos formulários.
| `timeout_seconds` | Servidor → Timeout | Em segundos. Padrão `30`. | | `timeout_seconds` | Servidor → Timeout | Em segundos. Padrão `30`. |
| `environment` | Servidor → Ambiente | `development` ou `production`. | | `environment` | Servidor → Ambiente | `development` ou `production`. |
> **Atenção:** o campo "Porta" do formulário define a porta exposta no host, não a > **Atenção:** o campo "Porta (host)" do formulário define a porta exposta no host,
> porta interna. O `config.toml` sempre grava `port = 8080`. > não a porta interna. O `config.toml` sempre grava `port = 8080` (constante
> `containerAppPort` em `docker.go`).
### `[database]` ### `[database]`
+3 -1
View File
@@ -13,7 +13,9 @@ func GenerateConfigTOML(cv ConfigValues) (string, error) {
// [server] // [server]
sb.WriteString("# Server Configuration\n") sb.WriteString("# Server Configuration\n")
sb.WriteString("[server]\n") sb.WriteString("[server]\n")
sb.WriteString("port = 8080\n") // Always containerAppPort: the container listens on this port internally; the
// user's port is the host-side mapping (see RunAppClienteContainer).
sb.WriteString(fmt.Sprintf("port = %d\n", containerAppPort))
sb.WriteString(fmt.Sprintf("timeout_seconds = %s\n", cv.Server["timeout"])) sb.WriteString(fmt.Sprintf("timeout_seconds = %s\n", cv.Server["timeout"]))
sb.WriteString(fmt.Sprintf("environment = %q\n", cv.Server["environment"])) sb.WriteString(fmt.Sprintf("environment = %q\n", cv.Server["environment"]))
sb.WriteString("\n") sb.WriteString("\n")
+5 -1
View File
@@ -11,6 +11,10 @@ import (
const networkName = "app-dono_app" const networkName = "app-dono_app"
// containerAppPort is the port the app cliente container listens on internally.
// The user-provided port is only the host-side mapping (<host port>:containerAppPort).
const containerAppPort = 8080
func RunContainer(image string, name string, port int) error { func RunContainer(image string, name string, port int) error {
cmd := exec.Command( cmd := exec.Command(
@@ -123,7 +127,7 @@ func RunAppClienteContainer(image, containerName, configPath, configDestinationP
args := []string{ args := []string{
"run", "-d", "run", "-d",
"-u", uidGid, "-u", uidGid,
"-p", fmt.Sprintf("%s:8080", cv.Server["port"]), "-p", fmt.Sprintf("%s:%d", cv.Server["port"], containerAppPort),
"--name", containerName, "--name", containerName,
"--network", networkName, "--network", networkName,
"--restart", "unless-stopped", "--restart", "unless-stopped",
+1 -1
View File
@@ -172,7 +172,7 @@ func InitialModel() Model {
serverForm: NewFormStep("Servidor", []FormField{ serverForm: NewFormStep("Servidor", []FormField{
{ {
Id: "port", Id: "port",
Label: "Porta", Label: "Porta (host)",
Placeholder: "8081", Placeholder: "8081",
Default: strconv.FormatInt(cfg.Server.Port, 10), Default: strconv.FormatInt(cfg.Server.Port, 10),
Type: FieldTypeNumber, Type: FieldTypeNumber,