logoComputeSphere
Deployment

How to Deploy a Django App on ComputeSphere

P
By Peter Ekhator
•3 min read•

A Django project reaches a live HTTPS URL on ComputeSphere with one command, csph deploy, once it reads its settings from the environment and runs under Gunicorn in a container. This guide walks through those two changes, the deploy, and then environment variables, migrations, a custom domain and autoscaling. You don't run a server, a process manager or a certificate renewal yourself.

Prefer to start from a working app? Clone the ComputeSphere Django example and follow along.

Before you start

  • A Django project that runs locally
  • Docker installed locally
  • A ComputeSphere account — a 14-day trial; a card is required to start, and you're charged from day 15 unless you cancel

Install the csph CLI

brew install computesphere/cli/csph
# or
npm install -g @computesphere/csph

Then sign in:

csph auth login

Get Django production-ready

Add Gunicorn to requirements.txt, and read your host and secret settings from the environment instead of hardcoding them:

import os

DEBUG = os.environ.get("DEBUG", "False") == "True"
SECRET_KEY = os.environ["SECRET_KEY"]
ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",")

Containerize your app

This Dockerfile collects static files at build time and serves the app with Gunicorn. The entrypoint runs migrations once, then starts the server:

FROM python:3.12-slim
WORKDIR /app
ENV PYTHONUNBUFFERED=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN python manage.py collectstatic --noinput
EXPOSE 8000
CMD ["sh", "-c", "python manage.py migrate --noinput && gunicorn myproject.wsgi:application --bind 0.0.0.0:8000"]

Replace myproject with your project's package name.

Deploy

From your project directory:

csph deploy

ComputeSphere builds the image, runs it on a spherelet, terminates TLS, and returns a public URL. Set the service port to 8000 — the port Gunicorn binds — and ComputeSphere routes public traffic to it:

https://violet-heron.computesphere.app

Set environment variables

Keep SECRET_KEY, database credentials, and host settings out of your image:

csph services variables set DEBUG=False ALLOWED_HOSTS=violet-heron.computesphere.app --service <service-id> --environment <environment-id>
csph services secrets set SECRET_KEY="$SECRET_KEY" DATABASE_URL="$DATABASE_URL" --service <service-id> --environment <environment-id>

csph services list shows the service id and csph environments list the environment id.

Set SECRET_KEY and DATABASE_URL in your shell first, for example from a file or your password manager, so the secret itself never appears in the command or your shell history.

Point DATABASE_URL at the database you already run. Add each custom domain you serve from to ALLOWED_HOSTS.

Add a custom domain

Open Console → Domains, add your hostname, and create the CNAME it shows pointing to your service URL:

Type    Name    Value
CNAME   app     violet-heron.computesphere.app

ComputeSphere issues and auto-renews the SSL certificate. Remember to add the new hostname to ALLOWED_HOSTS.

Scale with spherelets

A spherelet is your unit of compute, and you pay a fixed price per spherelet. Tune Gunicorn workers inside each spherelet, run as many spherelets as you need, and turn on autoscaling with a minimum, a maximum, and a target CPU. There are no per-seat fees, and every plan includes data out each month (10 GB to 1,000 GB, by plan), so scaling up stays predictable. Autoscaling is a Team plan feature; on Hobby and Pro you set the spherelet count yourself.

Your app is in production

Your Django project now runs on ComputeSphere under Gunicorn, with HTTPS, its settings in variables and secrets, migrations applied, and your own domain.

Next step: get started and run csph deploy from your project, or book a 15-minute demo.

Predictable cloud, from your first push.

Fixed price per spherelet, flat plan per team — ship without DevOps or surprise bills.

Start free trial

14-day free trial

Share this article

Ship your next service on ComputeSphere

Predictable per-spherelet pricing, a flat plan per team, and managed primitives built in — no DevOps, no surprise bills.

Deploy your first app in minutes.

Connect a repo or start from a template — live URL, SSL, and zero DevOps, on predictable monthly pricing. 14-day free trial.