[Pulp-dev] Using Gunicorn and Static Files

Patrick Creech pcreech at redhat.com
Tue Oct 9 13:11:24 UTC 2018


On Wed, 2018-10-03 at 16:28 -0400, Eric Helms wrote:
> Howdy,
> 
> When switching a deployment over to use gunicorn, DEBUG = TRUE for serving static files stopped working. I endeavored to follow the production install method using collectstatic. This required
> setting STATIC_ROOT which appeared to not be set by default.
> 
>  1) Is there a default value for STATIC_ROOT I can set for collectstatic?
>  2) Can gunicorn serve these static files for me?
> 
> I realize the documentation calls for serving static files via a webserver like nginx or Apache. However, that becomes a bit overkill in something like a container deployment. If I run a separate
> webserver, then I would run it as a separate container and have to mount the static files volume. This felt like overkill to me to have a persistent volume to store and mount static files instead of
> the application server providing them for the application.
> 
> Any thoughts and help are appreciated.
> 
> Eric

Eric,

I got curious and took a look into your situation.

I came across this project, suggested to be used by heroku, to achieve the goal you are working towards: http://whitenoise.evans.io/en/stable/

It comes with django middleware support out of the box, so all you would need to do is to 'pip install whietnoise' and edit the MIDDLEWARE collection in the settings.py to include it,  You want it to
load AFTER SecurityMiddleware, but BEFORE everything else, so make it the second line, here: https://github.com/pulp/pulp/blob/master/pulpcore/pulpcore/app/settings.py#L91

For your deployment model, it shouldn't be hard to apply a patch to the code at a stage in your container process to inject this middleware into the settings.py

Otherwise, it's the standard 'staticfiles' process for django,  They have it simplified in step 1 here: http://whitenoise.evans.io/en/stable/django.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20181009/b79d681b/attachment.sig>


More information about the Pulp-dev mailing list