Gitlab Community Edition Instance

Skip to content
Snippets Groups Projects
Verified Commit 8b99731e authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Adding whitenoise so serving static files becomes less painful

parent 0bcdeaba
Branches
Tags
1 merge request!19Whitenoise
Pipeline #
......@@ -2,7 +2,7 @@
FROM python:3.6 as python
COPY backend/requirements.txt .
RUN pip install -r requirements.txt
RUN curl https://gitlab.gwdg.de/snippets/51/raw --output words
RUN curl -s https://gitlab.gwdg.de/snippets/51/raw --output words
FROM node:carbon as node
......
......@@ -16,9 +16,6 @@ class IsUserGenericPermission(permissions.BasePermission):
def has_permission(self, request: HttpRequest, view: View) -> bool:
""" required by BasePermission. Check if user is instance of any
of the models provided in class' models attribute """
log.warn("Checking permission of request %s on view %s for user %s",
request, view, request.user)
assert self.models is not None, (
"'%s' has to include a `models` attribute"
% self.__class__.__name__
......@@ -29,7 +26,7 @@ class IsUserGenericPermission(permissions.BasePermission):
user.get_associated_user(), models) for models in self.models)
if not is_authorized:
log.warn('User %s has no permission to view %s',
log.warn('User "%s" has no permission to view %s',
user.username, view.__class__.__name__)
return is_authorized
......
......@@ -55,6 +55,7 @@ MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'grady.urls'
......@@ -106,13 +107,14 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'node_modules'),
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
FIXTURE_DIRS = ['/core/fixtures/']
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
GRAPH_MODELS = {
'all_applications': True,
......@@ -131,10 +133,6 @@ MESSAGE_TAGS = {
messages.ERROR: 'alert-danger',
}
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
AUTH_USER_MODEL = 'core.UserAccount'
AUTH_PASSWORD_VALIDATORS = []
......@@ -163,13 +161,9 @@ LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
'django.server': {
'datefmt': '%d/%b/%Y %H:%M:%S',
'format': '[%(asctime)s] %(levelname)-10s %(name)-20s %(message)s',
},
'core': {
'datefmt': '%d/%b/%Y %H:%M:%S',
'format': '[%(asctime)s] %(levelname)-10s %(name)-20s "%(message)s"',
'datefmt': '%Y-%m-%d %H:%M:%S',
'format': '[%(asctime)s] [%(levelname)s] %(name)-20s %(message)s',
},
},
'filters': {
......
......@@ -9,3 +9,4 @@ xlrd~=1.0.0
pytest-cov~=2.5.1
pytest-django~=3.1.2
prospector~=0.12.7
whitenoise~=3.3.1
version: '3'
services:
postgres:
image: postgres:9.5
web:
build: .
restart: always
grady:
image: docker.gitlab.gwdg.de/j.michal/grady:master
command:
- /bin/sh
- -c
- |
sleep 5
python manage.py collectstatic --noinput
python manage.py migrate --noinput
gunicorn --bind 0.0.0.0:8000 grady.wsgi:application &
cd static/ && python -m http.server 8080
ports:
- "8000:8000"
- "8080:8080"
gunicorn --bind 0.0.0.0:8000 grady.wsgi:application
depends_on:
- postgres
restart: always
networks:
- default
expose:
- "8000"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment