AI Tool Pipelines — Automate Your WorkflowsAI Tool Pipelines

Every product was carefully curated by an AI Tool Pipelines editor. We may earn a commission from these links. Here's how we choose products and why you should trust us.

How to Deploy an AI Micro-SaaS on a VPS With Docker

By · 4 min read · Updated Dec 2, 2026

Launch checklist for deploying an AI micro-SaaS on a VPS: Docker, HTTPS, secrets, backups, monitoring, spend caps

To deploy an AI micro-SaaS on a VPS, put the app in a Docker container, run it next to Postgres behind a reverse proxy that handles HTTPS, keep your model API keys in an environment file, back up the database every night, and add an uptime check. A single 2 to 4 vCPU, 4 to 8 GB server costs $9 to $15 a month and carries most micro-SaaS products through their first few hundred paying customers.

Key takeaways

  • One VPS with Docker Compose (app, Postgres, Caddy) is enough for most micro-SaaS launches.
  • The model runs at OpenAI or Anthropic, so the server only needs to handle web traffic and queues: 4 to 8 GB of RAM.
  • Coolify or Dokploy gives you Heroku-style git deploys on your own VPS for free.
  • The launch-day must-haves: HTTPS, secrets out of git, nightly off-server backups, uptime alerts, and a spend cap at your model provider.
  • Move off a single VPS when you need zero-downtime deploys or one server can no longer keep up, not before.

Why a VPS instead of a platform

Vercel, Render and Railway are great until your AI app needs a background worker, a long-running request, or a queue. Then the bill climbs per service. On a VPS you pay one flat price and run whatever processes you need. My opinion: for a micro-SaaS under a few thousand dollars a month in revenue, a VPS is the cheaper and simpler home, as long as you do the checklist below. Our production deployment guide covers the app side; this one covers the server.

The architecture: three containers

Diagram of an AI micro-SaaS on one VPS: Caddy handles HTTPS and forwards to the app container, which talks to Postgres and calls the OpenAI or Anthropic API
yaml
services:
  app:
    build: .
    restart: unless-stopped
    env_file: .env
    depends_on: [db]

  db:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - db_data:/var/lib/postgresql/data

  caddy:
    image: caddy:2
    restart: unless-stopped
    ports: ["80:80", "443:443"]
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data

volumes:
  db_data:
  caddy_data:
docker-compose.yml for a single-server micro-SaaS. Caddy gets HTTPS certificates automatically.
text
app.yourproduct.com {
  reverse_proxy app:3000
}
Caddyfile

The launch-day checklist

Seven-item launch checklist for an AI micro-SaaS on a VPS: HTTPS, secrets out of git, firewall, nightly backups, uptime alerts, model spend cap, log rotation
  • HTTPS on every domain. Caddy or Coolify does this. Stripe webhooks and OAuth logins will not work without it.
  • Secrets out of git. API keys live in .env on the server, never in the repo.
  • Firewall. Only ports 22, 80 and 443 open. Postgres should never be reachable from the internet.
  • Nightly off-server backups. A pg_dump to object storage. Test one restore before launch.
  • Uptime alerts. A free uptime monitor hitting a /health endpoint every minute.
  • A hard spend cap at your model provider. Set a monthly limit at OpenAI or Anthropic below what would hurt.
  • Log rotation. Docker logs fill disks. Set max-size in the Docker daemon config.

When to outgrow one server

Move to two servers or a managed platform when one of these is true: you need deploys with zero downtime, the database needs more memory than the app, or a single outage would cost you real money. Before that, a bigger VPS plan is a two-minute upgrade and usually the right answer.

“Your first hundred customers do not need Kubernetes. They need HTTPS, a backup you have tested, and a spend cap.”

Frequently asked questions

Frequently asked questions

Can I host a SaaS on a VPS?

Yes. Many micro-SaaS products run on a single VPS with Docker, Postgres and a reverse proxy until they reach hundreds or thousands of customers.

How big a VPS does an AI SaaS need?

If the model runs at an API provider, 2 vCPUs and 4 to 8 GB of RAM is usually enough at launch. Add RAM if you run Coolify, workers or a local model.

What is Coolify?

An open-source, self-hosted deployment panel. It builds your app from git on each push and handles domains, HTTPS and databases on your own server.

Is a VPS cheaper than Vercel for an AI app?

Often, once you need background workers, long requests or a database. A VPS charges one flat monthly price for all of them.

How do I back up a SaaS on a VPS?

Run a nightly pg_dump of the database, copy it to storage outside the server, keep at least two weeks, and test a restore before launch.