Skip to main content
Betadocs
DocsStatusSupportPricing
  • Introduction
    • Introduction to Webgune
    • How Webgune works
    • Creating an account
    • Creating your first project
    • Exploring the dashboard
  • Deployment

    • Deploying from GitHub
    • Deploying a Docker image
    • How builds work
    • Deployments and rollback
    • Environment variables
    • Custom start command
    • Health check
    • Database migrations

    Web apps

    • Web applications
      • Supported frameworks
      • Next.js
      • React / Vite
      • Node.js
      • Python
      • PHP
      • Go

    Bots & workers

    • Discord bots
    • Workers

    Docker

    • Docker
      • Writing a Dockerfile
      • Public Docker images

    Databases

    • Databases
      • PostgreSQL
      • MySQL
      • MariaDB
      • MongoDB
      • Redis

    Observability

    • Logs and monitoring
    • Web terminal

    Scaling

    • Availability and scaling
    • Persistent volumes
    • Backups and restore
    • Sleep mode

    Platform

    • One microVM per service
    • Network and isolation
    • Platform security
    • Deploying a template
      • Template catalog
    • Free subdomains
    • Custom domains
    • Buying a domain
    • Hosting DNS for a domain bought elsewhere
    • Managing your DNS records
    • SSL certificates
    • Redirects
    • Shared projects
      • Roles and permissions
    • Real-time collaboration
    • Continuous deployment
      • The kx712.yml file
    • VS Code extension
    • Plans and pricing
    • Payments and invoices
    • Account or per-project subscription
    • API reference
    • API keys
    • Webgune CLI
    • MCP server
    • JavaScript / TypeScript SDK
    • Support tickets
    • Status page
    • AI assistant
    • FAQ
    • Limits and resources
    • Account security
    • Best practices
    • Troubleshooting

Services / Web applications

Python

Open as Markdown

A repository is built as a Python project if it contains a dependencies file (requirements.txt, pyproject.toml, Pipfile, setup.py) and a recognized application: Django, FastAPI, Flask or one of the frameworks listed below. A simple main.py, app.py, server.py or run.py script is also enough.

Python version

The image is python:<version>-alpine. The version is read, in order, from .python-version, runtime.txt, Pipfile then requires-python in pyproject.toml. With no indication, it is Python 3.12.

# .python-version
3.13

A lower bound like requires-python = ">=3.9" gives 3.12, not 3.9. An upper bound like ">=3.9,<3.12" gives 3.9.

Installing dependencies

The build chooses the tool based on the files present:

File presentCommand
uv.lockuv export --frozen --no-dev, then pip install of the result
poetry.lock or [tool.poetry] sectionpoetry install --only main --no-root
Pipfile with Pipfile.lockpipenv install --system --deploy
Pipfile alonepipenv install --system --skip-lock
requirements.txt (or requirements/production.txt, prod.txt, base.txt)pip install -r <file>
pyproject.toml or setup.py with no other filepip install .

Development dependencies are not installed with uv and Poetry. Gunicorn or Uvicorn are added if they are missing from your dependencies.

Unlike Node.js, a lock file is not mandatory. Without one, two builds may install different versions: pin the versions in requirements.txt (fastapi==0.115.6) or commit uv.lock or poetry.lock.

System libraries

The image is based on Alpine. The following packages are compiled thanks to libraries added automatically when the build sees them in your dependencies:

Python packageAdded for compilation
psycopg2, psycopgPostgreSQL client
mysqlclientMariaDB client
pillowlibjpeg, zlib, freetype
lxmllibxml2, libxslt
weasyprint, pycairo, shapely, gdal, pyodbc, python-ldap, pycurlcorresponding libraries

The base (build-base, libffi-dev, openssl-dev, git) is always present. A package with no precompiled version for Alpine is compiled from source: the first build is longer, later ones use the cache.

What does not work on Alpine: TensorFlow, PyTorch and opencv-python. The build log says so. Use opencv-python-headless, or a Dockerfile based on python:3.12-slim.

Variables set in the image

VariableValueEffect
PYTHONUNBUFFERED1print output appears right away in the Logs tab
PYTHONDONTWRITEBYTECODE1No .pyc files written to disk
PYTHONPATH/app:/app/srcOnly if the repository has Python code in src/

FastAPI

# main.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def root():
    return {"message": "Hello"}

@app.get("/healthz")
def healthz():
    return "ok"
# requirements.txt
fastapi==0.115.6
uvicorn[standard]==0.34.0

Generated command: uvicorn main:app --host 0.0.0.0 --port $PORT. The build itself looks for the file that creates the FastAPI() object: api/main.py gives api.main:app. Litestar, Starlette and Quart are started the same way.

Behind Webgune, the visitor's address arrives in X-Forwarded-For. For Uvicorn to take it into account, replace the start command with:

uvicorn main:app --host 0.0.0.0 --port $PORT --proxy-headers --forwarded-allow-ips="*"

Django

Generated command: gunicorn <project>.wsgi:application --bind 0.0.0.0:$PORT, based on the location of wsgi.py. Without wsgi.py, it is python manage.py runserver, which should be avoided in production.

If your settings define STATIC_ROOT, the build runs python manage.py collectstatic --noinput. If this command fails (often because SECRET_KEY is missing at build time), the build continues and the log says so.

Variables to plan for:

DJANGO_SECRET_KEY=a-long-random-value
DJANGO_ALLOWED_HOSTS=my-site.webgune.dev,www.example.com
DATABASE_URL=postgresql://user:password@host:5432/database
# settings.py
import os

SECRET_KEY = os.environ["DJANGO_SECRET_KEY"]
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", "").split(",")
CSRF_TRUSTED_ORIGINS = [f"https://{h}" for h in ALLOWED_HOSTS if h]
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
STATIC_ROOT = BASE_DIR / "staticfiles"

SECURE_PROXY_SSL_HEADER tells Django the request arrived over HTTPS: without it, forms may fail with a CSRF error. To serve static files, add WhiteNoise (whitenoise.middleware.WhiteNoiseMiddleware).

Migrations cannot run at build time, which has no access to the database. Run them at startup with a custom command:

python manage.py migrate --noinput && gunicorn myproject.wsgi:application --bind 0.0.0.0:$PORT --workers 2

Read Database migrations first: a migration run at startup causes problems when rolling back to the previous version.

Flask

Generated command: gunicorn '<module>:<app>' --bind 0.0.0.0:$PORT. Application factories are recognized: a def create_app(): in app/__init__.py gives gunicorn 'app:create_app()'. Bottle and Falcon are started the same way.

For several processes per instance:

gunicorn app:app --bind 0.0.0.0:$PORT --workers 2 --timeout 60

Each Gunicorn process loads the application into memory. Count one process's memory multiplied by the number of --workers (Limits and resources).

Data applications

ToolGenerated command
Streamlitstreamlit run <file> --server.port=$PORT --server.address=0.0.0.0
Gradiopython <file>, with GRADIO_SERVER_NAME=0.0.0.0 and GRADIO_SERVER_PORT=$PORT
Dashgunicorn '<module>:server' if your code contains server = app.server, otherwise python <file>
Chainlitchainlit run <file> --host 0.0.0.0 --port $PORT
Panelpanel serve <file> --address 0.0.0.0 --port $PORT

Tornado, aiohttp, CherryPy and simple scripts are launched with python <file>: your code must read PORT and listen on 0.0.0.0.

import os
from aiohttp import web

app = web.Application()
web.run_app(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))

Documentation sites

MkDocs (mkdocs.yml), Pelican (pelicanconf.py) and Sphinx (conf.py or docs/conf.py) are built as a static site and served by Nginx. A repository that contains both mkdocs.yml and a Flask application stays an application.

Replacing the command

A Procfile at the root of the repository replaces the generated command:

web: gunicorn myproject.wsgi:application --bind 0.0.0.0:$PORT --workers 3

The service's start command, in its settings, has the same effect without touching the repository (Custom start command).

Common errors

SymptomCauseWhat to do
"Framework not detected"No dependencies file, or application not foundAdd requirements.txt, or a Procfile
Compilation fails on gcc or a .h headerPackage with no Alpine version and no known libraryDockerfile based on python:3.12-slim
DisallowedHostDomain missing from ALLOWED_HOSTSAdd the service's domain
CSRF error when submitting a formDjango does not know the request is over HTTPSSECURE_PROXY_SSL_HEADER and CSRF_TRUSTED_ORIGINS
ModuleNotFoundError on your own codeCode in a subfolder that cannot be importedPut the code in src/ or at the root
Stop with code 137Too many --workers for the service's memoryReduce --workers

Updated on November 20, 2026

Node.jsPreviousPHPNext

On this page

Python versionInstalling dependenciesSystem librariesVariables set in the imageFastAPIDjangoFlaskData applicationsDocumentation sitesReplacing the commandCommon errors
© 2026 WebguneBack to the site