VxCloud
Docs/Guides/Backend deployments
🐍Backend deployments

A working FastAPI + Postgres in fifteen minutes

The FastAPI wizard talks to the same MetalDB you provision in the Databases tab. Connection string is generated, stored in Vault, and injected into the FastAPI container at deploy time.

15 minIntermediateFastAPIPythonPostgresMetalDBVault
Pick how you want to follow along

In the dashboard (UI)

You will visit two wizards: Databases → MetalDB to provision Postgres, then Development → FastAPI to deploy the app pointing at that database.

1

Provision MetalDB first

Dashboard → Databases → tab "Cloud" → MetalDB card → Deploy. The wizard collects: Target VM Hostname/IP, SSH Username, SSH Key Pair, Database Name, Database User, Database Password, port (default 5432), Postgres Version, and optional replication / backup toggles.

  • Use the Test SSH Connection button before clicking Deploy.
  • Enable Backup if this is anything other than a throwaway demo — VxCloud will write nightly backups to the same VM (or to S3 if configured).
2

Wait for MetalDB to come up

The progress bar walks: 10% session start → 40% terraform apply → 70% Postgres systemd unit running → 90% admin role created → 100% connection details written to Vault. The dashboard shows the connection string and pgAdmin URL when ready.

3

Open the FastAPI wizard

Dashboard → Development → FastAPI Application → Deploy. Step 1 (Server Configuration) is identical to the Next.js flow — pick the same VM you put MetalDB on, or a different VM that can reach it on port 5432.

4

Step 2 — Application Source (Git)

Paste your FastAPI repo URL. The wizard expects a project with requirements.txt or pyproject.toml at the root and an entry point exposing FastAPI() — the conventional `main.py` with `app = FastAPI()`.

5

Step 3 — FastAPI Configuration

Set App Name, Python Version (3.12 / 3.11 / 3.10), and worker count for uvicorn/gunicorn. The wizard enables --workers automatically based on the chosen CPU count.

6

Step 4 — Application Settings + DATABASE_URL

Set App Port (8000), Entry Point (`main.py:app`), Requirements File (`requirements.txt`). In Environment Variables, paste: DATABASE_URL=postgres://<dbuser>:<dbpass>@<vm-ip>:5432/<dbname> Use the credentials Vault wrote when MetalDB came up — the dashboard surfaces them as a copy button on the MetalDB resource page.

Tip: Prefer not to paste secrets at all? Click the "Pull from Vault" link next to the Environment Variables textarea — VxCloud injects the MetalDB connection string at deploy time and never persists it in the form.
7

Deploy and verify

Hit Deploy. After ~3 minutes you will see the API live at http://<vm-ip>:8000/docs (FastAPI auto-docs). The Monitoring tab shows both resources — MetalDB and the FastAPI service — linked under the same workspace.

Stuck halfway through? Email [email protected] — most replies land within an hour during weekdays.

All guides

Was this page helpful?