Klashe
11/10/2025, 3:04 AMMarvin
11/10/2025, 3:04 AMMarvin
11/10/2025, 3:10 AM# on your VM
python3 -m venv /opt/prefect
source /opt/prefect/bin/activate
pip install -U prefect
# optional: for production, point Prefect Server at Postgres
export PREFECT_SERVER_DATABASE_CONNECTION_URL='<postgresql+asyncpg://user:pass@db-host:5432/prefect>'
# start Prefect Server (serves API + UI)
prefect server start --host 0.0.0.0 --port 4200
2) Connect clients/workers to your VM
# on machines running flows/workers
export PREFECT_API_URL="http://<vm-ip>:4200/api"
Notes:
- For quick tests, the server can run with SQLite; for production use PostgreSQL. Ensure pg_trgm is enabled in Postgres for text search (CREATE EXTENSION pg_trgm).
- Migrations run automatically on start; you can also manage them with:
- prefect server database upgrade|downgrade|reset
Option B — Docker Compose (typical for VMs)
- The docs include a ready-to-use docker-compose.yaml that brings up Prefect Server and a Postgres database:
- Docker Compose guide
- Steps (summary):
- Copy the compose file from the docs
- Set PREFECT_SERVER_DATABASE_CONNECTION_URL to your Postgres service (e.g., `postgresql+asyncpg://prefect:prefect@postgres:5432/prefect`)
- docker compose up -d
- Access the UI at http://<vm-ip>:4200 and set PREFECT_API_URL="http://<vm-ip>:4200/api" on your clients/workers
Security and production hardening
- Reverse proxy/TLS and external URLs: Advanced self-hosting
- Auth, headers, and UI/API URL config: Security settings
If you share your VM OS and whether you prefer Docker or bare-metal—and if you’ll use Postgres—I can tailor a concrete install script or a docker-compose.yaml for you.