Skip to main content

Deployments & App Management

Deploy Python Django apps

We support running Django apps as docker compose configurations. Here is some configuration settings needed to run them properly.

Configure Django properly

Add to django_project/settings.py proper ALLOWED_HOSTS. DollarDeploy exposes APP_HOSTNAME to every running app, so make sure settings.py checks for that:

ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]

if os.environ.get("APP_HOSTNAME"):
    ALLOWED_HOSTS.append(os.environ.get("APP_HOSTNAME"))

Also pass this variable down to the app in the docker-compose.yml as well:

  web:
    environment:
      - APP_HOSTNAME=${APP_HOSTNAME}

Configure port

DollarDeploy assumes you run on port 3000 by default. Add to environment var

    • PORT: 8000

Deploy for the first time

You will need to create the admin user. Login to the server and execute in the app folder:

docker compose exec -e DJANGO_SUPERUSER_PASSWORD="admin123" web python manage.py createsuperuser --noinput --username admin --email admin@example.com

This will create the user so you can login into the app.

Essential settings

  • App type: Docker Compose
  • Post start shell command:
    docker compose exec web python manage.py migrate
  • Add env variable: PORT=8000

Example repository

Here is the repository you can fork / template to start your Python project.

GitHub - huksley/python-django-lithium: Django starter project with 🔋
Django starter project with 🔋. Contribute to huksley/python-django-lithium development by creating an account on GitHub.