2026-11-27 · tandoor · recipes · docker · self-hosting
Self-Host Tandoor Recipes with Docker Compose
Deploy Tandoor Recipes with Docker Compose: PostgreSQL, persistent media, reverse proxy with HTTPS, and first-run admin hardening.
- Total RAM
- 885.6 MB
- Startup
- 104.9 s
- Port
- 8000
- HTTP
- 302
web_recipes 845.4 MB
· db_recipes 40.2 MB
What Tandoor Recipes does and what it needs
Tandoor Recipes is a Django app for managing a recipe collection, planning meals, and generating shopping lists. It imports recipes from sites that expose schema.org JSON-LD or microdata, supports full-text search with PostgreSQL trigram similarity, and lets you share cookbooks with family or friends. It is not designed as a public site; the built-in permission system is basic.
The stack is two containers: the ghcr.io/tandoorrecipes/recipes web app and a PostgreSQL database. The app stores uploaded recipe images and static files in a media volume, so you need persistent storage for both the database and media. The upstream project does not publish a minimum RAM figure. Idle memory is modest, but recipe imports, image processing, and search queries scale with collection size and concurrent users.
Prerequisites, ports, and volume constraints
- A Linux VPS with Docker Engine 24+ and the Compose plugin.
- A domain name pointed at the server if you want HTTPS. For local testing you can use
localhostand an SSH tunnel. - The container runs an internal Nginx reverse proxy on port
80(proxying to Gunicorn over/tmp/tandoor.sock). We publish it on127.0.0.1:8000so only your host reverse proxy can reach it. - Three named volumes:
recipes_staticfor collected static assets,recipes_mediafor uploaded images, andrecipes_dbfor PostgreSQL data. Named volumes avoid permission mismatches on both the database and media directories. - Generate a Django
SECRET_KEYand a database password. Never commit them.
Production Docker Compose setup
Create a project directory and write the Compose file. The app reads SECRET_KEY, TZ, ALLOWED_HOSTS, and the POSTGRES_* variables from the environment. DB_ENGINE defaults to PostgreSQL in the image, but set it explicitly.
mkdir -p ~/tandoor && cd ~/tandoor
cat <<'EOF' > compose.yml
services:
db_recipes:
image: postgres:16-alpine
restart: unless-stopped
volumes:
- recipes_db:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-djangodb}
POSTGRES_USER: ${POSTGRES_USER:-djangouser}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-djangouser} -d $${POSTGRES_DB:-djangodb}"]
interval: 10s
timeout: 5s
retries: 5
web_recipes:
image: ghcr.io/tandoorrecipes/recipes:latest
restart: unless-stopped
depends_on:
db_recipes:
condition: service_healthy
ports:
- "127.0.0.1:8000:80"
volumes:
- recipes_static:/opt/recipes/staticfiles
- recipes_media:/opt/recipes/mediafiles
environment:
SECRET_KEY: ${SECRET_KEY}
TZ: ${TZ:-UTC}
ALLOWED_HOSTS: ${ALLOWED_HOSTS:-*}
DB_ENGINE: django.db.backends.postgresql
POSTGRES_HOST: db_recipes
POSTGRES_PORT: 5432
POSTGRES_DB: ${POSTGRES_DB:-djangodb}
POSTGRES_USER: ${POSTGRES_USER:-djangouser}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
healthcheck:
test: ["CMD-SHELL", "test -S /tmp/tandoor.sock && wget -q -O /dev/null http://127.0.0.1:80/"]
interval: 10s
timeout: 5s
retries: 30
start_period: 30s
volumes:
recipes_static:
recipes_media:
recipes_db:
EOF
Now create the .env file with generated secrets. Use openssl rand -hex 32 for both values. Set ALLOWED_HOSTS to your domain; for local testing use localhost.
cat <<EOF > .env
SECRET_KEY=$(openssl rand -hex 32)
POSTGRES_PASSWORD=$(openssl rand -hex 32)
TZ=UTC
ALLOWED_HOSTS=recipes.example.com
POSTGRES_DB=djangodb
POSTGRES_USER=djangouser
EOF
Start the stack and check logs. On first boot, Tandoor starts its embedded Nginx immediately while running Django database migrations and collectstatic, so port 8000 returns HTTP 502 until Gunicorn binds /tmp/tandoor.sock (typically 60–90 seconds). The healthcheck marks web_recipes healthy once Gunicorn is serving requests.
docker compose up -d
docker compose logs -f web_recipes
Once the app is healthy, create the first admin user. The image includes Django management commands; run createsuperuser inside the web container.
docker compose exec web_recipes python manage.py createsuperuser
Reverse proxy, HTTPS, and first-run hardening
Tandoor is a Django app that expects X-Forwarded-Proto and X-Forwarded-For headers when behind a proxy. It also uses WebSockets for some real-time features, so the proxy must upgrade connections. Uploaded recipe images can be large; set a client body limit of at least 20 MB.
Example Caddyfile on the host (Caddy runs outside this Compose stack):
recipes.example.com {
encode gzip
request_body {
max_size 20MB
}
reverse_proxy 127.0.0.1:8000 {
header_up X-Forwarded-Proto {scheme}
header_up X-Forwarded-For {remote_host}
}
}
For Nginx, add proxy_set_header Upgrade $http_upgrade; and proxy_set_header Connection "upgrade"; in the location block, plus client_max_body_size 20M;.
After the first login, go to the Django admin and disable open signup if you do not want strangers creating accounts. Tandoor is not a public site; keep registration closed and invite users manually. Also set ALLOWED_HOSTS to the exact domain; Django rejects requests with mismatched Host headers.
If you are testing without a domain, keep the port bound to 127.0.0.1 and use an SSH tunnel: ssh -L 8000:127.0.0.1:8000 user@server. Then open http://localhost:8000. Do not expose port 8000 publicly without TLS.
Updating, backups, and common pitfalls
Update the app and database images with Compose. The app runs migrations on startup, so take a backup first.
cd ~/tandoor
docker compose pull
docker compose up -d
Back up the database and media volume. Use pg_dump inside the database container and archive the media volume with a temporary container.
docker compose exec -T db_recipes pg_dump -U djangouser djangodb > backup-$(date +%F).sql
docker run --rm -v tandoor_recipes_media:/media -v "$PWD":/backup alpine tar czf /backup/media-$(date +%F).tar.gz -C /media .
Two operational pitfalls from the docs and common issues:
- ALLOWED_HOSTS mismatch. If you see
DisallowedHosterrors, the domain inALLOWED_HOSTSdoes not match the Host header. Set it to the exact domain, comma-separated for multiple hosts, and restart the web container. - Media volume permissions. If recipe images fail to upload, check that the
recipes_mediavolume is writable by the container user. Avoid bind mounts for media on systems with SELinux or restrictive umask; named volumes handle ownership more predictably.
Database migrations run automatically on container start. If an update fails mid-migration, restore the SQL dump and the media archive before retrying.
Measured in our sandbox run: total memory 885.6 MB (sum of per-container peaks over a 30s idle window after startup) across 2 containers; largest container 845.4 MB; published port(s) 8000; HTTP probe returned 302. The run took 104.9s with the image already cached; a fresh server also has to download it. Required secret(s) POSTGRES_PASSWORD, SECRET_KEY were generated for the test run, as the tutorial instructs. Container breakdown: web_recipes 845.4 MB, db_recipes 40.2 MB.
Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.