serving the static css files

alexΒ 13th May 2024 at 12:35pm

Since the staticfiles should be gathered by Django itself, I put the corresponding command in the entrypoint β€” thus, it will not be necessary to commit the static files, as they are generated upon container boot.

# Source the .env file
source /code/.env

python manage.py collectstatic --settings=tutogarden.settings.production

# Execute the command passed to the container
exec "$@"

And then, since I need nginx to serve these same files, something like this works:

podman run -d -p 1234:8000 --mount type=bind,source=./staticfiles,target=/code/staticfiles my-django-app

the staticfiles is populated with files by the container, and then one can access them on the host system, as they are mirrored on ./staticfiles. Nice!

With this, it seems like the static content is being properly served: I can access the admin panel on my domain. ✨