One command to go from a GitHub release to a running, routable, database-backed service.
GopherCaptain is a Go CLI that runs on a Linux server and handles the full stack: fetch a binary from GitHub Releases, configure systemd, allocate a port, set up nginx routing, and create a MariaDB database with scoped credentials.
gophercaptain deploy myapi -v v1.2.0 -r api.example.com
This single command:
- Downloads the
v1.2.0release binary from GitHub - Creates a MariaDB database and user with a generated password
- Writes an env file with PORT, DB credentials, and any extra vars
- Creates a systemd unit, enables and starts the service
- Writes an nginx config for
api.example.com→localhost:<port> - Records everything in a local SQLite state database
Upgrade, rollback, and remove are equally simple. If any step fails during deploy, all completed steps are rolled back automatically.
Server:
- Linux (amd64 or arm64) with systemd
- nginx installed with
sites-available/sites-enabledlayout - MariaDB installed and running
- Root or sudo access
For building from source:
- Go 1.24+
Download the latest binary for your architecture:
# amd64
curl -Lo /usr/local/bin/gophercaptain \
https://github.com/ecairns22/GopherCaptain/releases/latest/download/gophercaptain-linux-amd64
chmod +x /usr/local/bin/gophercaptain
# arm64
curl -Lo /usr/local/bin/gophercaptain \
https://github.com/ecairns22/GopherCaptain/releases/latest/download/gophercaptain-linux-arm64
chmod +x /usr/local/bin/gophercaptaingo install github.com/ecairns22/GopherCaptain/cmd/gophercaptain@latestOr clone and build:
git clone https://github.com/ecairns22/GopherCaptain.git
cd GopherCaptain
go build -o gophercaptain ./cmd/gophercaptain/
sudo mv gophercaptain /usr/local/bin/sudo gophercaptain initThis creates the required directories and writes a config template to /etc/gophercaptain/gophercaptain.conf.
Edit /etc/gophercaptain/gophercaptain.conf with your GitHub token and settings:
[github]
token = "ghp_YOUR_TOKEN"
owner = "your-github-username"
[mariadb]
admin_password_file = "/root/.mariadb_password"Write your MariaDB root password to the file referenced above:
echo "your-mariadb-password" > /root/.mariadb_password
chmod 600 /root/.mariadb_passwordRun init again to verify the connection:
sudo gophercaptain initsudo gophercaptain deploy myapi -v v1.2.0 -r api.example.com -e LOG_LEVEL=info| Command | Description |
|---|---|
gophercaptain init |
Create directories, write config template, test connections |
gophercaptain deploy <repo> |
Deploy a service from a GitHub release |
gophercaptain upgrade <service> |
Upgrade to a new version (auto-rollback on failure) |
gophercaptain rollback <service> |
Swap back to the previous version |
gophercaptain remove <service> |
Stop and remove all artifacts for a service |
gophercaptain list |
Show all deployed services with live status |
gophercaptain status <service> |
Detailed status for a service |
gophercaptain inspect <service> |
Print generated configs (credentials redacted) |
-v, --version string Release tag (default: latest)
-p, --port int Override port (default: auto-assign from range)
-r, --route string Route rule: "api.example.com" or "/api"
--route-type string "subdomain" or "path" (inferred from --route)
-n, --name string Service name (default: repo name)
-e, --env strings Extra env vars: -e KEY=VALUE (repeatable)
--no-db Skip database creation
--config-file Write TOML config file instead of env vars
--drop-db Also drop the MariaDB database and user
-y, --yes Skip confirmation prompt
Default path: /etc/gophercaptain/gophercaptain.conf (override with GOPHERCAPTAIN_CONFIG env var)
[github]
token = "ghp_..." # GitHub personal access token (repo scope)
owner = "your-username" # Default repo owner
[ports]
range_start = 3000 # Port allocation range start
range_end = 4000 # Port allocation range end (exclusive)
[mariadb]
host = "127.0.0.1"
port = 3306
admin_user = "root"
admin_password_file = "/root/.mariadb_password"
[nginx]
sites_dir = "/etc/nginx/sites-available"
enabled_dir = "/etc/nginx/sites-enabled"
[releases]
asset_pattern = "{{.Name}}-linux-amd64" # Go template for matching release assetsgit clone https://github.com/ecairns22/GopherCaptain.git
cd GopherCaptain
# Run tests (no external services needed)
go test ./...
# Run vet
go vet ./...
# Build
go build ./cmd/gophercaptain/
# Cross-compile
GOOS=linux GOARCH=amd64 go build -o gophercaptain-linux-amd64 ./cmd/gophercaptain/
GOOS=linux GOARCH=arm64 go build -o gophercaptain-linux-arm64 ./cmd/gophercaptain/MariaDB integration tests are gated behind an environment variable:
GOPHERCAPTAIN_TEST_MARIADB=password go test ./internal/db/...cmd/gophercaptain/ CLI entrypoint + commands
internal/
config/ TOML config loading
orchestrator/ Coordinates deploy/upgrade/rollback/remove flows
state/ SQLite state store (services + history)
github/ GitHub Releases API client
systemd/ Unit file generation + service lifecycle
nginx/ Config generation + test + reload
db/ MariaDB database/user lifecycle
ports/ Sequential port allocation
creds/ Credential generation + env file writing
health/ TCP health check
runner/ Command execution abstraction (testable)
See LICENSE for details.