summaryrefslogtreecommitdiffstats
path: root/cmd/ship/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/ship/main.go')
-rw-r--r--cmd/ship/main.go92
1 files changed, 0 insertions, 92 deletions
diff --git a/cmd/ship/main.go b/cmd/ship/main.go
index cd2b0c1..f7d95c1 100644
--- a/cmd/ship/main.go
+++ b/cmd/ship/main.go
@@ -3,100 +3,8 @@ package main
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os" 5 "os"
6
7 "github.com/bdw/ship/cmd/ship/env"
8 "github.com/bdw/ship/cmd/ship/host"
9 "github.com/spf13/cobra"
10) 6)
11 7
12var (
13 // Persistent flags
14 hostFlag string
15
16 // Version info (set via ldflags)
17 version = "dev"
18 commit = "none"
19 date = "unknown"
20)
21
22const banner = `
23 ~
24 ___|___
25 | _ |
26 _|__|_|__|_
27 | SHIP | Ship apps to your VPS
28 \_________/ with automatic HTTPS
29 ~~~~~~~~~
30`
31
32var rootCmd = &cobra.Command{
33 Use: "ship",
34 Short: "Ship apps and static sites to a VPS with automatic HTTPS",
35 Long: banner + `
36A CLI tool for deploying applications and static sites to a VPS.
37
38How it works:
39 Ship uses only SSH to deploy - no agents, containers, or external services.
40 It uploads your binary or static website, creates a systemd service, and configures Caddy
41 for automatic HTTPS. Ports are assigned automatically. Your app runs directly on the VPS
42 with minimal overhead.
43
44Requirements:
45 • A VPS with SSH access (use 'ship host init' to set up a new server)
46 • An SSH config entry or user@host for your server
47 • A domain pointing to your VPS
48
49Examples:
50 # Deploy a Go binary
51 ship --binary ./myapp --domain api.example.com
52
53 # Deploy with auto-generated subdomain (requires base domain)
54 ship --binary ./myapp --name myapp
55
56 # Deploy a static site
57 ship --static --dir ./dist --domain example.com
58
59 # Update config without redeploying binary
60 ship --name myapp --memory 512M --cpu 50%
61 ship --name myapp --env DEBUG=true
62
63 # Set up a new VPS with base domain
64 ship host init --host user@vps --base-domain apps.example.com`,
65 RunE: runDeploy,
66 SilenceUsage: true,
67 SilenceErrors: true,
68}
69
70func init() {
71 // Persistent flags available to all subcommands
72 rootCmd.PersistentFlags().StringVar(&hostFlag, "host", "", "VPS host (SSH config alias or user@host)")
73
74 // Root command (deploy) flags
75 rootCmd.Flags().String("binary", "", "Path to Go binary (for app deployment)")
76 rootCmd.Flags().Bool("static", false, "Deploy as static site")
77 rootCmd.Flags().String("dir", ".", "Directory to deploy (for static sites)")
78 rootCmd.Flags().String("domain", "", "Custom domain (optional if base domain configured)")
79 rootCmd.Flags().String("name", "", "App name (default: inferred from binary or directory)")
80 rootCmd.Flags().Int("port", 0, "Port override (default: auto-allocate)")
81 rootCmd.Flags().StringArray("env", nil, "Environment variable (KEY=VALUE, can be specified multiple times)")
82 rootCmd.Flags().String("env-file", "", "Path to .env file")
83 rootCmd.Flags().String("args", "", "Arguments to pass to binary")
84 rootCmd.Flags().StringArray("file", nil, "Config file to upload to working directory (can be specified multiple times)")
85 rootCmd.Flags().String("memory", "", "Memory limit (e.g., 512M, 1G)")
86 rootCmd.Flags().String("cpu", "", "CPU limit (e.g., 50%, 200% for 2 cores)")
87
88 // Add subcommands
89 rootCmd.AddCommand(listCmd)
90 rootCmd.AddCommand(logsCmd)
91 rootCmd.AddCommand(statusCmd)
92 rootCmd.AddCommand(restartCmd)
93 rootCmd.AddCommand(removeCmd)
94 rootCmd.AddCommand(env.Cmd)
95 rootCmd.AddCommand(host.Cmd)
96 rootCmd.AddCommand(uiCmd)
97 rootCmd.AddCommand(versionCmd)
98}
99
100func main() { 8func main() {
101 if err := rootCmd.Execute(); err != nil { 9 if err := rootCmd.Execute(); err != nil {
102 fmt.Fprintf(os.Stderr, "Error: %v\n", err) 10 fmt.Fprintf(os.Stderr, "Error: %v\n", err)