From 8a3cff0dd7eb88cadb73a6df4e14f85450d63317 Mon Sep 17 00:00:00 2001 From: bndw Date: Sat, 24 Jan 2026 16:55:52 -0800 Subject: 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 --- cmd/ship/host/init.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cmd/ship/host/init.go') 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 { if host == "" { host = st.GetDefaultHost() } + baseDomain, _ := cmd.Flags().GetString("base-domain") if host == "" { return fmt.Errorf("--host is required") @@ -64,7 +65,6 @@ func runInit(cmd *cobra.Command, args []string) error { fmt.Println("-> Configuring Caddy...") caddyfile := `{ - email admin@example.com } import /etc/caddy/sites-enabled/* @@ -100,7 +100,11 @@ import /etc/caddy/sites-enabled/* fmt.Println(" Caddy is active") } - st.GetHost(host) + hostState := st.GetHost(host) + if baseDomain != "" { + hostState.BaseDomain = baseDomain + fmt.Printf(" Base domain: %s\n", baseDomain) + } if st.GetDefaultHost() == "" { st.SetDefaultHost(host) fmt.Printf(" Set %s as default host\n", host) -- cgit v1.2.3