diff options
| author | Clawd <ai@clawd.bot> | 2026-02-17 07:59:50 -0800 |
|---|---|---|
| committer | Clawd <ai@clawd.bot> | 2026-02-17 07:59:50 -0800 |
| commit | d97bb6f53eefd2139115d39bca7e17d565222472 (patch) | |
| tree | 428f230dffad49d166bc521609dd3ee236a42010 /cmd/ship/root_v2.go | |
| parent | 3e34265c8a6ea1ec300f987206afb25bad645677 (diff) | |
Fix port collision bug, add --container-port flag
Port allocation:
- Use atomic flock-based allocation via /etc/ship/next_port
- Prevents race conditions when multiple deploys run concurrently
- Each app still gets its port stored in /etc/ship/ports/<name>
Docker container port:
- Add --container-port flag (default 80)
- Template now uses {{.ContainerPort}} instead of hardcoded 80
- Supports containers that listen on 8080, 3000, etc.
Diffstat (limited to 'cmd/ship/root_v2.go')
| -rw-r--r-- | cmd/ship/root_v2.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/cmd/ship/root_v2.go b/cmd/ship/root_v2.go index 4101d4e..aa81d1e 100644 --- a/cmd/ship/root_v2.go +++ b/cmd/ship/root_v2.go | |||
| @@ -43,6 +43,7 @@ func initV2() { | |||
| 43 | rootV2Cmd.Flags().String("ttl", "", "Auto-delete after duration (e.g., 1h, 7d)") | 43 | rootV2Cmd.Flags().String("ttl", "", "Auto-delete after duration (e.g., 1h, 7d)") |
| 44 | rootV2Cmd.Flags().StringArray("env", nil, "Environment variable (KEY=VALUE)") | 44 | rootV2Cmd.Flags().StringArray("env", nil, "Environment variable (KEY=VALUE)") |
| 45 | rootV2Cmd.Flags().String("env-file", "", "Path to .env file") | 45 | rootV2Cmd.Flags().String("env-file", "", "Path to .env file") |
| 46 | rootV2Cmd.Flags().Int("container-port", 80, "Port the container listens on (Docker only)") | ||
| 46 | 47 | ||
| 47 | // Check for SHIP_PRETTY env var | 48 | // Check for SHIP_PRETTY env var |
| 48 | if os.Getenv("SHIP_PRETTY") == "1" { | 49 | if os.Getenv("SHIP_PRETTY") == "1" { |
| @@ -78,6 +79,7 @@ func runDeployV2(cmd *cobra.Command, args []string) error { | |||
| 78 | opts.TTL, _ = cmd.Flags().GetString("ttl") | 79 | opts.TTL, _ = cmd.Flags().GetString("ttl") |
| 79 | opts.Env, _ = cmd.Flags().GetStringArray("env") | 80 | opts.Env, _ = cmd.Flags().GetStringArray("env") |
| 80 | opts.EnvFile, _ = cmd.Flags().GetString("env-file") | 81 | opts.EnvFile, _ = cmd.Flags().GetString("env-file") |
| 82 | opts.ContainerPort, _ = cmd.Flags().GetInt("container-port") | ||
| 81 | 83 | ||
| 82 | // deployV2 handles all output and exits | 84 | // deployV2 handles all output and exits |
| 83 | deployV2(path, opts) | 85 | deployV2(path, opts) |
