Skip to content

Quick Start — Python

Deploy a Python (Flask, FastAPI, Django) app from git push to a live HTTPS URL in 5 minutes.

Prerequisites

  • A Python project (requirements.txt + entry point)
  • Python 3.11+ on your machine (python3 --version)
  • The paas CLI:
    curl -fsSL https://get.di2amp.com/install.sh | sh
    paas --version
    

If you don't already have a Python project, scaffold a Flask one:

mkdir hello-paas && cd hello-paas
cat > app.py <<'EOF'
from flask import Flask
import os
app = Flask(__name__)

@app.route('/')
def home():
    return 'Hello from PaaS Runtime!\n'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))
EOF
echo "flask>=3.0" > requirements.txt
echo "gunicorn>=21.0" >> requirements.txt
git init && git add -A && git commit -m "init"

Step 1 — Authenticate

paas login

This opens your browser for SSO (Keycloak). Token is stored in ~/.config/paas/credentials.toml.

Verify:

$ paas whoami
octave@paas.local (member of: paas-default)

Step 2 — Create the app

paas apps create hello-paas

Output:

✓ Created app hello-paas
  URL:    https://hello-paas.runtime.di2amp.com
  Region: eu-fr-1
  Plan:   free
  Git:    https://git.di2amp.com/octave/hello-paas.git

Verify the git remote:

$ git remote -v
paas    https://git.di2amp.com/octave/hello-paas.git (fetch)
paas    https://git.di2amp.com/octave/hello-paas.git (push)

Step 3 — Add a Procfile

PaaS uses Buildpacks (Paketo) to build images. You only need a Procfile for process types:

# Procfile
web: gunicorn app:app --bind 0.0.0.0:$PORT --workers 2

Commit:

git add Procfile && git commit -m "add Procfile"

Step 4 — Push to deploy

git push paas main

You'll see live build logs:

remote: ─────── PaaS Build ───────
remote: → Detected: python (paketo-buildpacks/python)
remote: → Installing Python 3.12.1
remote: → Installing pip 24.0
remote: → Running: pip install -r requirements.txt
remote: → Image:    registry.di2amp.com/octave/hello-paas:abc1234
remote: → SBOM:     ✓ generated, 23 packages
remote: → CVE scan: ✓ 0 critical, 0 high
remote:
remote: ─────── PaaS Deploy ───────
remote: → Process types: web
remote: → Replicas:      1/1 ready
remote: → Rollout:       v1 → v2 (canary 10% → 100%)
remote: → Health:        / returns 200 OK
remote: → URL:           https://hello-paas.runtime.di2amp.com
remote:
remote: ✓ Deployed in 52s

Step 5 — Verify the app is live

$ curl https://hello-paas.runtime.di2amp.com/
Hello from PaaS Runtime!

The dashboard shows runtime status:

https://ma30.di2amp.com/runtime/dashboard/apps/hello-paas

Next steps

Add a managed PostgreSQL

paas addons create database --type postgres --plan free --name db

DATABASE_URL is injected automatically:

import os
import psycopg
conn = psycopg.connect(os.environ['DATABASE_URL'])

Tail logs

paas logs --tail

Run a one-off command

paas run -- python manage.py migrate

Add a worker process

In Procfile:

web: gunicorn app:app --bind 0.0.0.0:$PORT
worker: celery -A app worker --loglevel=info

Then push and scale:

git push paas main
paas ps:scale worker=2

Set environment variables

paas config:set DJANGO_SECRET_KEY="$(openssl rand -base64 32)"
paas config:set FLASK_ENV=production

See also