Infrastructure
Deploy Command
One-command production deployment. Build, upload, and configure your server with grit deploy.
How it works
01
Build
Cross-compiles your Go binary for Linux (GOOS=linux GOARCH=amd64 CGO_ENABLED=0). If a frontend/ directory exists, builds the frontend first.
Terminal
grit deploy --host user@server.com --domain myapp.com
02
Upload
Uploads the compiled binary to the remote server via SCP. Creates the deployment directory if it does not exist.
Terminal
# Binary uploaded to /opt/my-app/my-app# via: scp -P 22 bin/my-app user@server.com:/opt/my-app/
03
Systemd service
Creates and enables a systemd service unit. The service auto-restarts on failure and reads environment variables from your .env file.
my-app.service
[Unit]Description=my-appAfter=network.target[Service]Type=simpleUser=www-dataWorkingDirectory=/opt/my-appExecStart=/opt/my-app/my-appRestart=on-failureEnvironmentFile=/opt/my-app/.env[Install]WantedBy=multi-user.target
04
Caddy reverse proxy
If --domain is provided, configures Caddy as a reverse proxy with automatic HTTPS via Let's Encrypt.
Caddyfile
myapp.com {reverse_proxy localhost:8080encode gzipheader {X-Frame-Options "DENY"X-Content-Type-Options "nosniff"-Server}}
Flags
| Flag | Env Var | Description |
|---|---|---|
| --host | DEPLOY_HOST | SSH host (e.g. user@server.com) |
| --port | - | SSH port (default: 22) |
| --key | DEPLOY_KEY_FILE | Path to SSH private key |
| --domain | DEPLOY_DOMAIN | Domain for Caddy reverse proxy |
| --app-port | - | Port the app runs on (default: 8080) |