全部指南

Python · Django

Run with gunicorn and connect the database via DATABASE_URL.

  1. 1Start command

    With only manage.py it starts the dev server; use gunicorn in production (add it to requirements.txt).

    bash
    python manage.py migrate && gunicorn mysite.wsgi --bind 0.0.0.0:$PORT --workers 2
  2. 2Connect PostgreSQL

    Create postgres in the same project and reference it. Read it with dj-database-url.

    bash
    oc db create postgres --name db
    oc variables set DATABASE_URL='${{db.DATABASE_URL}}'
    oc variables set ALLOWED_HOSTS='*'
  3. 3Deploy (pick one)

    ① Connect GitHub: Project → Add service → GitHub repository (deploys on push) ② From this folder: oc up --wait (builds even without a Dockerfile) ③ Upload a folder or zip in the console: Add service → Upload source

    bash
    oc login
    oc project create my-app --link
    oc up --wait

相关指南