diff options
| author | Clawd <ai@clawd.bot> | 2026-02-18 21:11:48 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-18 21:11:48 -0800 |
| commit | 6d4ffd6e2176e82e81033adf878cba959817336f (patch) | |
| tree | 85e062321c1bc4b38b2229603b97cabc820fd111 | |
| parent | 7b05505db7e964e400b779f76e8a2023bda93fe1 (diff) | |
fix: pass container port (not host port) as PORT env var
Docker deployments were passing the host port as PORT to the container,
but the port mapping routes traffic to container port. This caused apps
that read PORT from env to listen on the wrong port inside the container.
| -rw-r--r-- | cmd/ship/deploy_impl_v2.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/ship/deploy_impl_v2.go b/cmd/ship/deploy_impl_v2.go index ec5c4a3..bfec9d3 100644 --- a/cmd/ship/deploy_impl_v2.go +++ b/cmd/ship/deploy_impl_v2.go | |||
| @@ -120,8 +120,15 @@ func deployDockerV2(ctx *deployContext) *output.ErrorResponse { | |||
| 120 | return output.Err(output.ErrBuildFailed, err.Error()) | 120 | return output.Err(output.ErrBuildFailed, err.Error()) |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | // Determine container port | ||
| 124 | containerPort := ctx.Opts.ContainerPort | ||
| 125 | if containerPort == 0 { | ||
| 126 | containerPort = 80 | ||
| 127 | } | ||
| 128 | |||
| 123 | // Generate and write env file | 129 | // Generate and write env file |
| 124 | envContent := fmt.Sprintf("PORT=%d\nSHIP_NAME=%s\nSHIP_URL=%s\n", port, name, ctx.URL) | 130 | // Use containerPort so the app listens on the correct port inside the container |
| 131 | envContent := fmt.Sprintf("PORT=%d\nSHIP_NAME=%s\nSHIP_URL=%s\n", containerPort, name, ctx.URL) | ||
| 125 | for _, e := range ctx.Opts.Env { | 132 | for _, e := range ctx.Opts.Env { |
| 126 | envContent += e + "\n" | 133 | envContent += e + "\n" |
| 127 | } | 134 | } |
| @@ -134,10 +141,6 @@ func deployDockerV2(ctx *deployContext) *output.ErrorResponse { | |||
| 134 | } | 141 | } |
| 135 | 142 | ||
| 136 | // Generate systemd unit | 143 | // Generate systemd unit |
| 137 | containerPort := ctx.Opts.ContainerPort | ||
| 138 | if containerPort == 0 { | ||
| 139 | containerPort = 80 | ||
| 140 | } | ||
| 141 | service, err := templates.DockerService(map[string]string{ | 144 | service, err := templates.DockerService(map[string]string{ |
| 142 | "Name": name, | 145 | "Name": name, |
| 143 | "Port": strconv.Itoa(port), | 146 | "Port": strconv.Itoa(port), |
