diff options
| author | bndw <ben@bdw.to> | 2026-01-24 16:55:52 -0800 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2026-01-24 16:55:52 -0800 |
| commit | 8a3cff0dd7eb88cadb73a6df4e14f85450d63317 (patch) | |
| tree | 461e3b7af3a71f92c8a916f2e4578a63e2d92f13 /cmd/ship/host/init.go | |
| parent | 9c222e3fe49c6786c1719b6100564d413d7f8db6 (diff) | |
Add auto-generated subdomain feature
When a base domain is configured on a host (e.g., apps.example.com),
deployments automatically get a subdomain ({name}.apps.example.com).
Custom --domain can still be provided to route both domains.
- Add BaseDomain field to Host state
- Add --base-domain flag to host init
- Add 'ship host set-domain' command to update base domain
- Update deploy flow to auto-generate subdomains
- Fix error display (errors were being silently swallowed)
- Remove placeholder email from Caddyfile template
Diffstat (limited to 'cmd/ship/host/init.go')
| -rw-r--r-- | cmd/ship/host/init.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/ship/host/init.go b/cmd/ship/host/init.go index ea25922..27f67af 100644 --- a/cmd/ship/host/init.go +++ b/cmd/ship/host/init.go | |||
| @@ -26,6 +26,7 @@ func runInit(cmd *cobra.Command, args []string) error { | |||
| 26 | if host == "" { | 26 | if host == "" { |
| 27 | host = st.GetDefaultHost() | 27 | host = st.GetDefaultHost() |
| 28 | } | 28 | } |
| 29 | baseDomain, _ := cmd.Flags().GetString("base-domain") | ||
| 29 | 30 | ||
| 30 | if host == "" { | 31 | if host == "" { |
| 31 | return fmt.Errorf("--host is required") | 32 | return fmt.Errorf("--host is required") |
| @@ -64,7 +65,6 @@ func runInit(cmd *cobra.Command, args []string) error { | |||
| 64 | 65 | ||
| 65 | fmt.Println("-> Configuring Caddy...") | 66 | fmt.Println("-> Configuring Caddy...") |
| 66 | caddyfile := `{ | 67 | caddyfile := `{ |
| 67 | email admin@example.com | ||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | import /etc/caddy/sites-enabled/* | 70 | import /etc/caddy/sites-enabled/* |
| @@ -100,7 +100,11 @@ import /etc/caddy/sites-enabled/* | |||
| 100 | fmt.Println(" Caddy is active") | 100 | fmt.Println(" Caddy is active") |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | st.GetHost(host) | 103 | hostState := st.GetHost(host) |
| 104 | if baseDomain != "" { | ||
| 105 | hostState.BaseDomain = baseDomain | ||
| 106 | fmt.Printf(" Base domain: %s\n", baseDomain) | ||
| 107 | } | ||
| 104 | if st.GetDefaultHost() == "" { | 108 | if st.GetDefaultHost() == "" { |
| 105 | st.SetDefaultHost(host) | 109 | st.SetDefaultHost(host) |
| 106 | fmt.Printf(" Set %s as default host\n", host) | 110 | fmt.Printf(" Set %s as default host\n", host) |
