Reputation: 663
Running a Django project Google Flexible Environment with Gunicorn as entry-point so that I can use geventworkers.
Cant seem to figure out how to server the static files properly.
I have set STATIC_URL = '/static/'
and STATIC_ROOT = 'static'
in Django settings.
I've also ran manage.py collectstatic
and the files do get copied correctly, yet my django rest framework swagger cant find its files.
For the convenience I had already added TEMPLATES
to my settings as well.
This used to work before I started using geventworkers.
Im trying to get nginx to serve the files, but I cant seem to edit the nginx config. Of the docker that it runs by default.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
'rest_framework.templates',
'rest_framework_swagger.templates',
os.path.join(BASE_DIR, 'website'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
],
},
}
]
Upvotes: 1
Views: 326
Reputation: 2319
Gunicorn doesn't serve static content, so you have to create a Google Cloud Storage bucket to serve static content.
Create a bucket and upload the static files.
gsutil mb gs://<your-gcs-bucket>
gsutil defacl set public-read gs://<your-gcs-bucket>
gsutil rsync -R static/ gs://<your-gcs-bucket>/static
In settings.py
set the value of STATIC_URL
as following:
STATIC_URL = 'https://storage.googleapis.com/<your-gcs-bucket>/static/'
You can folow step by step guide to see how to deploy the app to the App Engine flexible environment.
Upvotes: 1