add dockerfile and prep for prod

This commit is contained in:
Tobias Brunner 2025-01-30 15:12:50 +01:00
parent 8c9671602b
commit 9aeab6ee3b
No known key found for this signature in database
5 changed files with 94 additions and 1 deletions

40
docker/Caddyfile Normal file
View file

@ -0,0 +1,40 @@
{
auto_https off
log {
output stderr
format console
level ERROR
}
}
:8080 {
# Health check endpoint
handle /healthz {
respond "OK" 200
}
# Handle static files
handle /static/* {
uri strip_prefix /static
root * /app/staticfiles
file_server
}
# Handle media files
handle /media/* {
uri strip_prefix /media
root * /app/mediafiles
file_server
}
# Proxy all other requests to Gunicorn
handle {
reverse_proxy unix//run/gunicorn.sock
}
respond /healthz "OK" 200
header Cache-Control no-cache
# Basic compression for better performance
encode gzip
}

18
docker/run.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/sh -e
echo "Applying database migrations"
python -m hub migrate
echo "Starting Caddy"
caddy start --config /etc/caddy/Caddyfile
echo "Starting Gunicorn"
exec \
gunicorn \
-w 4 \
--access-logfile None \
--error-log - \
--capture-output \
--pythonpath /app/.venv/lib/python3.13/site-packages/ \
--bind unix:/run/gunicorn.sock \
hub.wsgi:application