Harbor CLI
A CLI tool for those small side projects that only run a few services. Harbor allows you to:
- 🛠️ Define your services in a configuration file
- 🔄 Generate a Caddyfile to reverse proxy certain services to subdomains
- 🚀 Launch your services in a tmux session with Caddy and your services automatically proxied
Installation
npm i -g @abyrd9/harbor-cli
Prerequisites
Before using Harbor, make sure you have the following installed:
- Caddy (for reverse proxy)
- tmux (for terminal multiplexing)
- jq (for JSON processing within tmux)
Quick Start
- Initialize your development environment:
harbor dock
- Add new services to your configuration:
harbor moor
- Update your Caddyfile:
harbor anchor
- Launch your services:
harbor launch
Configuration
Harbor uses two main configuration files:
harbor.json
Contains your service configurations that are used to generate the Caddyfile and launch the services:
{
"domain": "localhost",
"services": [
{
"name": "frontend",
"path": "./vite-frontend",
"command": "npm run dev",
"port": 3000,
"subdomain": "app"
},
{
"name": "api",
"path": "./go-api",
"command": "go run .",
"port": 8080,
"subdomain": "api"
},
{
"name": "dashboard",
"path": "./vite-frontend",
"command": "npx drizzle-kit studio",
}
]
}
Note: The dashboard service is a bit special. This is a drizzle studio instance to view your database. There's no subdomain value and no port declared because it typically runs at local.drizzle.studio
. This will still be running and viewable in your tmux session, but it won't be automatically proxied.
Caddyfile
Automatically generated reverse proxy configuration:
api.localhost {
reverse_proxy localhost:8080
}
app.localhost {
reverse_proxy localhost:3000
}
Note: Some services may be tricky with Caddy and getting HMR to work or whatever other problems. Feel free to tinker with the Caddyfile or the subdomain values in the harbor config file in order to get things running. Maybe in the future there will be examples for common cases.
Commands
harbor dock
: Generate a new harbor.json fileharbor moor
: Add new services to your harbor.json fileharbor anchor
: Update your Caddyfile from the current harbor.json fileharbor launch
: Start all services defined in your harbor.json file in a tmux session
Terminal Multiplexer
Harbor uses tmux for managing your services. Some useful shortcuts:
Ctrl+a d
: Detach from sessionCtrl+a c
: Create new windowCtrl+a n
: Next windowCtrl+a p
: Previous windowCtrl+q
: Quit session
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT