No configuration file in your repository. Qovery does not read a
qovery.yml, .qovery.yml or .qovery.toml, and there is no qovery init. Projects, environments and services are created in the Console, with qovery api, or with Terraform. For the full path from a repository to a running app with commands only, see Deploy with the CLI and API.Prerequisites
- A Django project in a GitHub, GitLab or Bitbucket repository, with a
requirements.txt. - A Qovery account and a cluster: create one in your cloud account, connect your own cluster, or try it on your laptop.
- These packages in
requirements.txt:gunicorn,psycopg[binary],dj-database-urlandwhitenoise.
Prepare the settings
Read the configuration from environment variables insettings.py:
settings.py
"mysite.health.HealthCheckMiddleware" first in MIDDLEWARE, and "whitenoise.middleware.WhiteNoiseMiddleware" right after "django.middleware.security.SecurityMiddleware". Replace mysite with your project package.
Kubernetes probes call the pod by its IP address, which is not in ALLOWED_HOSTS, so Django would answer them with 400 Bad Request. This middleware answers /healthz before Django checks the host:
mysite/health.py
Add a production Dockerfile
Create aDockerfile at the root of the repository:
Dockerfile
python:3.13-slimis the official Python image without build tools.psycopg[binary]ships its own PostgreSQL client library, so no system package is needed.PYTHONUNBUFFERED=1sends logs straight to stdout, where Qovery reads them.- Copying
requirements.txtbefore the code keeps the dependency layer cached when only the code changes. collectstaticruns at build time and writes the files toSTATIC_ROOT. WhiteNoise serves them from there.- The container runs as a non-root user.
- Gunicorn binds to
0.0.0.0, not127.0.0.1, so Kubernetes can reach it.execmakes Gunicorn the main process, so it receives the stop signal and shuts down cleanly.
.dockerignore with at least .git, .venv, __pycache__ and staticfiles to keep the image small.
Port and health check
The application listens on port8000 and answers GET /healthz with 200. Use both values when you create the application in Qovery.
Connect PostgreSQL
The application and the migration job read the connection string fromDATABASE_URL. Create PostgreSQL, then expose its connection string under that name at the environment scope, so every service of the environment gets it.
- Qovery database (development)
- Blueprint (production)
- In the environment, click New Service and pick PostgreSQL. Keep the visibility private, then create and deploy it. See Create a Database.
- Open the Variables section of the environment, find the built-in variable
QOVERY_POSTGRESQL_Z<ID>_DATABASE_URL_INTERNAL, select Create alias, and name itDATABASE_URL.
Set the variables
The
qovery.io domain shows in the Console once the application is created. Add your custom domains to DJANGO_ALLOWED_HOSTS, separated by commas.
Run the migrations
Runmigrate in a lifecycle job built from the same repository and Dockerfile, triggered on the Deploy event, with these CMD arguments:
migrate in the start command instead works for a single instance, but every instance then runs it at boot, and a failed migration leaves the application crashing in a loop.
Deploy
- Console
- With a coding agent
1
Create a project and an environment
Follow steps 1 and 2 of Deploy Your First Application. Pick the cluster the environment runs on.
2
Add PostgreSQL
Create the database and the
DATABASE_URL variable as described in Connect PostgreSQL.3
Create the application
In the environment, click New Service › Create application, select Git Repository, then your repository and branch. Leave Root Application Path empty unless the Dockerfile is in a subfolder.
4
Set the port
Add port
8000 with the protocol HTTP, and turn on Publicly Accessible. Qovery serves it over HTTPS on port 443.5
Set the health checks
Set the readiness and liveness probes to type HTTP, path
/healthz, port 8000. See Service Health Checks.6
Add the variables
Click Create, without deploying yet. Then open the Variables section of the environment and add the other variables listed in Set the variables at the environment scope, so the migration job gets them too.
DATABASE_URL already exists from the previous step. Mark keys and passwords as secrets.7
Create the migration job
Click New Service › Create lifecycle job, select the same repository, branch and Dockerfile, and trigger it on the Deploy event (
START) with the CMD arguments ["python", "manage.py", "migrate", "--noinput"]. Set the number of restarts to 0. See Run the migrations.8
Deploy
Deploy the environment. Qovery deploys the database, then the job, then the application, builds the image from your Dockerfile and gives the application a URL on
qovery.io. Follow the progress in the Deployment logs tab.Troubleshooting
The CLI commands below use the organization and project selected withqovery context set. Run it first, or add --organization and --project to each command.
Deployment fails on the health check
Deployment fails on the health check
Gunicorn listens on another port, or on
127.0.0.1. Check that the port in Qovery is 8000, that Gunicorn binds to 0.0.0.0:${PORT}, and that HealthCheckMiddleware is first in MIDDLEWARE. Read the error lines with qovery environment deployment logs --environment "<env>" --service "<app>" --errors-only.Bad Request (400) in the browser
Bad Request (400) in the browser
The domain is missing from
DJANGO_ALLOWED_HOSTS. Add the qovery.io domain and your custom domains, then redeploy. A 403 CSRF verification failed on forms has the same cause, because CSRF_TRUSTED_ORIGINS is built from the same list.relation does not exist
relation does not exist
The migrations did not run against this database. Check that the job and the application read the same
DATABASE_URL at the environment scope, and read the job output with qovery log --job "<job name>".Static files return 404
Static files return 404
collectstatic did not run at build time, or WhiteNoise is not in MIDDLEWARE. Check the build logs for the collectstatic step. With DEBUG off, Django itself serves no static files.Next steps
Preview environments
Get a full copy of the environment for each pull request
Custom domain
Serve the application on your own domain
Auto deploy
Deploy on every push to the branch
Other frameworks
All framework guides