DEV Community

Alex Spinov
Alex Spinov

Posted on

CapRover Has a Free API — Heres How to Deploy Apps Like Heroku on Your Own Server

CapRover is a self-hosted PaaS — like Heroku but on your own VPS. One-click apps, automatic HTTPS, and Docker-based deployments with a beautiful dashboard.

Why CapRover?

  • Heroku-like experience: Git push to deploy
  • One-click apps: 100+ apps (WordPress, PostgreSQL, Redis, etc.)
  • Automatic HTTPS: Let's Encrypt
  • Docker-based: Any Dockerfile works
  • CLI deploys: caprover deploy
  • $5/mo: Run on any VPS
  • Free: Open source

Install (One Command)

docker run -p 80:80 -p 443:443 -p 3000:3000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /captain:/captain \
  caprover/caprover
Enter fullscreen mode Exit fullscreen mode

Setup wizard at http://YOUR_IP:3000

CLI Deploy

npm install -g caprover
caprover login
caprover deploy
Enter fullscreen mode Exit fullscreen mode

API: Create App

curl -X POST http://captain.example.com/api/v2/user/apps/appDefinitions/register \
  -H 'x-captain-auth: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"appName": "my-api", "hasPersistentData": false}'
Enter fullscreen mode Exit fullscreen mode

API: Deploy from Image

curl -X POST http://captain.example.com/api/v2/user/apps/appData/my-api \
  -H 'x-captain-auth: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"captainDefinitionContent": "{\"schemaVersion\":2, \"imageName\":\"node:20-alpine\"}"}'
Enter fullscreen mode Exit fullscreen mode

API: Enable HTTPS

curl -X POST http://captain.example.com/api/v2/user/apps/appDefinitions/enablessl \
  -H 'x-captain-auth: YOUR_TOKEN' \
  -d '{"appName": "my-api"}'
Enter fullscreen mode Exit fullscreen mode

API: Set Environment Variables

curl -X POST http://captain.example.com/api/v2/user/apps/appDefinitions/update \
  -H 'x-captain-auth: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "appName": "my-api",
    "envVars": [
      {"key": "DATABASE_URL", "value": "postgres://db:5432/mydb"},
      {"key": "NODE_ENV", "value": "production"}
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

captain-definition File

{
  "schemaVersion": 2,
  "dockerfilePath": "./Dockerfile"
}
Enter fullscreen mode Exit fullscreen mode

Or use built-in templates:

{
  "schemaVersion": 2,
  "templateId": "node/18.0.0"
}
Enter fullscreen mode Exit fullscreen mode

One-Click Apps

Deploy from the dashboard:

  • PostgreSQL, MySQL, MongoDB, Redis
  • WordPress, Ghost, Strapi
  • Grafana, Prometheus, Portainer
  • N8n, Minio, GitLab

Real-World Use Case

A freelance developer hosted 12 client projects on one $20 Hetzner VPS with CapRover. Each client gets their own subdomain with HTTPS. Total hosting cost: $20/mo instead of $240/mo on Heroku (12 x $20 hobby dynos).


Need to automate data collection? Check out my Apify actors for ready-made scrapers, or email spinov001@gmail.com for custom solutions.

Top comments (0)