Sass fix for permissions

This commit is contained in:
Oliver Marks 2018-01-30 14:19:39 +00:00
parent d345791fe3
commit 43a98f7164
9 changed files with 73 additions and 8 deletions

View File

@ -1,10 +1,17 @@
#FROM python:3.6-alpine
FROM python:3.6
ENV PYTHONUNBUFFERED 1
#RUN apk add --no-cache libev-dev git postgresql-dev gcc python3-dev musl-dev
#RUN apt update
#RUN apt install -y libev-dev libevdev2 git python3-dev
# Requirements have to be pulled and installed here, otherwise caching won't work
COPY ./requirements /requirements
RUN pip install --cache-dir ./cache/pip -r /requirements/local.txt \
&& groupadd -r django \
&& useradd -r -g django django
@ -20,6 +27,7 @@ RUN mkdir -p /var/log/gunicorn/ \
COPY ./compose/django/dev-gunicorn-mhackspace.sh /dev-gunicorn-mhackspace.sh
COPY ./compose/django/live-gunicorn-mhackspace.sh /live-gunicorn-mhackspace.sh
COPY ./compose/django/stage-gunicorn-mhackspace.sh /stage-gunicorn-mhackspace.sh
COPY ./compose/django/bjoern.py /bjoern.py
COPY ./compose/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh \
&& sed -i 's/\r//' /stage-gunicorn-mhackspace.sh \

42
compose/django/bjoern.py Normal file
View File

@ -0,0 +1,42 @@
"""
WSGI config for Maidstone Hackspace project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
import bjoern
from django.core.wsgi import get_wsgi_application
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
# apply Werkzeug WSGI middleware
# if os.environ.setdefault('DJANGO_DEBUG', 'False') is True:
from werkzeug.debug import DebuggedApplication
# application.wsgi_app = DebuggedApplication(application.wsgi_app, evalex=True)
application = DebuggedApplication(application, evalex=True, pin_security=True)
application.debug = True
bjoern.run(application, 'unix:/data/sockets/bjoern-mhackspace.sock')

View File

@ -2,4 +2,4 @@
#python /app/manage.py collectstatic --noinput
#python /app/manage.py compilescss
/usr/local/bin/gunicorn config.wsgi -w 2 -b unix:/data/sockets/dev-gunicorn-mhackspace.sock --reload --chdir=/app
/usr/local/bin/gunicorn config.wsgi -w 1 -b unix:/data/sockets/dev-gunicorn-mhackspace.sock --reload --chdir=/app

View File

@ -446,7 +446,8 @@ PAYMENT_PROVIDERS = {
}
SASS_PRECISION = 8
# Important this fixes permission issues by compiling in a temporary folder, instead of inside your project
SASS_PROCESSOR_ROOT = os.path.join('/tmp', 'sass')
SASS_PROCESSOR_INCLUDE_DIRS = [
str(APPS_DIR) + '/static/sass',
str(ROOT_DIR) + '/node_modules',

View File

@ -17,7 +17,7 @@ from .common import * # noqa
# DEBUG
# ------------------------------------------------------------------------------
DEBUG = env.bool('DJANGO_DEBUG', default=True)
DEBUG = True
TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
# SECRET CONFIGURATION
@ -169,7 +169,9 @@ AWS_S3_OBJECT_PARAMETERS = {
AWS_LOCATION = 'dev'
AWS_S3_SECURE_URLS = True
STATIC_URL = '%s/%s/' % (AWS_S3_ENDPOINT_URL, AWS_STORAGE_BUCKET_NAME)
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATICFILES_STORAGE = 'mhackspace.core.storage.SassStorageFix'
# COMPRESSOR
# ------------------------------------------------------------------------------

View File

@ -32,6 +32,9 @@ application = get_wsgi_application()
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
# apply Werkzeug WSGI middleware
if os.environ.setdefault('DEBUG', 'False') is True:
# if os.environ.setdefault('DJANGO_DEBUG', 'False') is True:
from werkzeug.debug import DebuggedApplication
application = DebuggedApplication(application, evalex=True)
# application.wsgi_app = DebuggedApplication(application.wsgi_app, evalex=True)
application = DebuggedApplication(application, evalex=True, pin_security=True)
application.debug = True

View File

@ -31,6 +31,7 @@ services:
depends_on:
- postgres
# - redis
# command: python /bjorne.py
command: /dev-gunicorn-mhackspace.sh
env_file: .env
volumes:
@ -76,4 +77,4 @@ services:
env_file: .env
volumes:
- ./mhackspace:/data
command: server /data
command: server --config-dir /tmp/minio /data

View File

@ -0,0 +1,6 @@
from storages.backends.s3boto3 import S3Boto3Storage
from django.conf import settings
class SassStorageFix(S3Boto3Storage):
base_url = settings.AWS_S3_ENDPOINT_URL

View File

@ -60,6 +60,8 @@ lxml==3.7.3
# ------------------------------------------------
gevent==1.2.2
gunicorn==19.7.1
#https://github.com/jonashaag/bjoern
#bjoern
# Your custom requirements go here
mock==2.0.0