Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I’m trying to deploy a Django application using a Digital Ocean Postgres database and Redis instance on App Platform.
Here is my App Spec:
alerts:
- rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
databases:
- cluster_name: postgres
engine: PG
name: postgres
production: true
version: "13"
- cluster_name: redis
engine: REDIS
name: redis
production: true
version: "6"
envs:
- key: DJANGO_ALLOWED_HOSTS
scope: RUN_TIME
value: ${APP_DOMAIN}
- key: DATABASE_URL
scope: RUN_TIME
value: ${postgres.DATABASE_URL}
- key: REDIS_URL
scope: RUN_TIME
value: ${redis.REDIS_URL}
name: myapp
region: fra
services:
- environment_slug: python
envs:
- key: DISABLE_COLLECTSTATIC
scope: RUN_AND_BUILD_TIME
value: "1"
github:
branch: main
deploy_on_push: true
repo: mygithubuser/mygithubrepo
http_port: 8080
instance_count: 1
instance_size_slug: basic-xxs
name: myapp
routes:
- path: /
run_command: gunicorn --worker-tmp-dir /dev/shm config.wsgi
source_dir: /
jobs:
- name: migrate
kind: PRE_DEPLOY
github:
repo: mygithubuser/mygithubrepo
branch: main
deploy_on_push: true
run_command: python manage.py migrate
envs:
- key: DISABLE_COLLECTSTATIC
value: "1"
scope: BUILD_TIME
static_sites:
- name: static
github:
repo: mygithubuser/mygithubrepo
branch: main
deploy_on_push: true
output_dir: staticfiles
routes:
- path: /static
I have tested this setup without the static_sites component and it builds and deploys OK, but I need my static files collected by Django with python manage.py collectstatic.
Thefore I’ve added the static_sites component but I now get the error:
django.core.exceptions.ImproperlyConfigured: Set the {postgres.DATABASE_URL} environment variable
I believe this is because the environment variables DATABASE_URL=${postgres.DATABASE_URL} is not available at build time, only at run time?
If so, why is there an example of static files being collected in the example Django app here using this method?
https://github.com/digitalocean/sample-django/blob/main/.do/app.yaml
How can you make collectstatic a part of the build/deploy process?
a6309a057c3f4cb38fb2e7feb67236
KFSys
ef1ed44cc2154be3bcbb2d727878f8
Devs Neonetworks
1e6b823ea20d4cb189a34a922f5588
Telmo Valverde
erik-jan martens
Henry Mui
anthonycarreon
garantieheld
Marin