Skip to content

Instantly share code, notes, and snippets.

@chlenc
Created July 18, 2025 14:42
Show Gist options
  • Save chlenc/ed987cffe91192f00fc3dc059186552b to your computer and use it in GitHub Desktop.
Save chlenc/ed987cffe91192f00fc3dc059186552b to your computer and use it in GitHub Desktop.
ship_fast.md
# Deploy It in Minutes: CapRover on a Bare‑Bones VPS
### Introduction
*Cannes, around 04:20 AM. The hackathon clock is merciless. Our funding‑rate bot is humming, but the graphs? Non‑existent. “Can we spin up ClickHouse and Grafana ****now****?” asks my teammate, already opening fluence.network in another tab.*
That night we refined a repeatable recipe: grab a cheap VPS, drop CapRover on top, deploy whatever we need — front‑end, microservice, or a full analytics stack — in **minutes**, not hours.
Below is the distilled playbook I wish I had earlier. Same conversational style as our arbitrage series, just more commands. 🔧
> Missed the funding‑rate arbitrage article? [Catch up here](https://x.com/defi_defiler/status/1932148079370838066) — the stack we deploy will power its dashboards.
---
## 1. Provision a VPS
Pick any cloud or bare‑metal provider you like — DigitalOcean, Hetzner, AWS Lightsail, your own homelab — the toolchain below works everywhere. Create a mid‑tier **Ubuntu 22.04** box (2–4 vCPU, 4–8 GB RAM gives ClickHouse and Grafana breathing room), add your **public SSH key**, and take note of the server’s **public IP**. That’s all you need for the rest of the guide.
---
## 2. SSH in & prep the box
```bash
ssh ubuntu@<VPS_IP>
# Always update first
apt update && sudo apt upgrade -y
```
### Install Docker & Compose
```bash
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker ubuntu # log out & back in to apply
# Docker Compose plugin
sudo apt install docker-compose-plugin -y
```
> Quick sanity check: `docker run hello-world` should spit out the classic handshake.
&#x20;**Open these ports in your VPS firewall / security group for CapRover & Docker Swarm to work:**
80, 443, 3000, 996, 7946, 4789, 2377/tcp
7946, 4789, 2377/udp
---
## 3. One‑liner CapRover install
CapRover is basically “Heroku + Traefik” in a single container.
```bash
docker run -d \
--name caprover \
-p 80:80 -p 443:443 -p 3000:3000 \
-e ACCEPTED_TERMS=true \
-e MAIN_NODE_IP_ADDRESS='YOUR_VPS_IP' \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /captain:/captain \
caprover/caprover
```
Wait \~30 seconds, then open:
`http://<LIGHTSAIL_IP>:3000`
Set your **root domain** (e.g., `vps.yourdomain.com`) and copy the suggested DNS records.
**Default caprover password: captain42**
---
## 4. Point a domain & get free SSL
1. In your DNS provider, add an **A record** for `captain.vps.yourdomain.com` → VPS IP.
2. Back in CapRover, hit **“Enable HTTPS”**. Under the hood Let’s Encrypt + Traefik handle certs.
3. Voilà — dashboard now at `https://captain.vps.yourdomain.com`.
>
---
## 5. Deploy ClickHouse & Grafana
### 5.1 Create an app: **clickhouse**
1. **Apps → Create new app →** name `clickhouse`.
2. Choose **“Method 3: deploy a pre‑built image”**.
3. Image name: `clickhouse/clickhouse-server:latest` (official image ➜ [https://hub.docker.com/r/clickhouse/clickhouse-server/](https://hub.docker.com/r/clickhouse/clickhouse-server/)).
4. **Ports**: leave 8123 (HTTP) & 9000 (native) exposed.
5. Hit **Deploy**.
### 5.2 Create an app: **grafana**
Same drill, new app:
* Image: `grafana/grafana:latest` (official image ➜ [https://hub.docker.com/r/grafana/grafana/](https://hub.docker.com/r/grafana/grafana/))
* Exposed port: **3000**
* Environment variable: `GF_SECURITY_ADMIN_PASSWORD=supersecret`
Deploy! CapRover auto‑assigns subdomains:
`https://clickhouse.vps.yourdomain.com`, `https://grafana.vps.yourdomain.com`
---
## 6. Wire Grafana → ClickHouse
1. Log into Grafana (`admin / supersecret`).
2. **Connections → Add data source → ClickHouse**.
3. URL: `https://clickhouse.vps.yourdomain.com:8123`
4. Auth: default `default / ''` (change in prod!).
5. Save & test — green check means success.
Now import a dashboard JSON or craft a panel showing average funding rates from your bot’s table. Instant visuals, zero glue code.
>
---
## 7. Automate the boring bits
* **Captain Definition files** let you version deployments (think docker‑compose YAML).
* Use CapRover CLI in CI/CD: `caprover deploy` on every `git push main`.
* Set up **scheduled backups**: ClickHouse → S3, Grafana → JSON export.
---
### What I Learned Doing This (Again and Again)
Speed isn’t just nice — it’s morale. When the idea–>prototype loop shrinks to minutes, the team stays in flow. CapRover isn’t magic, but it removes 80% of yak‑shaving:
* No fighting reverse proxies.
* No manual SSL renewals.
* No “wait, which port is that service on?”
The other 20 %? Still on you. Keep your secrets safe, monitor your disk, and rehearse restores. ☕️
---
## Ready to Ship?
Fork this guide, swap in your own services, and deploy something *today*.
Questions, war stories, or better tricks — my DMs are always open.
💬 Twitter — [https://twitter.com/defi\_defiler](https://twitter.com/defi_defiler)
💼 LinkedIn — [https://www.linkedin.com/in/chlenc](https://www.linkedin.com/in/chlenc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment