enh Servir ficheros estáticos con uwsgi en lugar de Whitenoise

parent 2e4142df
#.env
# DB
DB_NAME=manhattan
DB_USER=albert
DB_PASSWORD=einstein
DB_HOST=localhost
DJANGO_MANAGEPY_MIGRATE="on"
# app
DJANGO_SECRET_KEY=s+s6-^@s&=xg@l7!qsprhd5-1-0*wuh*0tjm_5)%uq(5q(nc4c
# For debugging and error reporting
DEBUG=False
......@@ -4,6 +4,7 @@ LABEL maintainer="Enrique Matías Sánchez <quique@unizar.es>"
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
# All output to stdout will be flushed immediately
ENV PYTHONUNBUFFERED 1
# Install packages needed to run your application (not build deps):
......@@ -16,7 +17,9 @@ RUN apt-get update \
libmariadbclient18 \
libpcre3 \
libxmlsec1-openssl \
mime-support
mime-support \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file to the container image
COPY requirements.txt ./
......@@ -31,6 +34,7 @@ RUN set -ex \
libmariadbclient-dev \
libpcre3-dev \
libxmlsec1-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $BUILD_DEPS \
&& pip install --no-cache-dir -r requirements.txt \
# && pip install gunicorn \
......@@ -64,10 +68,12 @@ ENV UWSGI_WSGI_FILE=manhattan_project/wsgi.py
ENV UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_UID=1000 UWSGI_GID=2000 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
# Number of uWSGI workers and threads per worker (customize as needed):
ENV UWSGI_WORKERS=2 UWSGI_THREADS=4
ENV UWSGI_WORKERS=4 UWSGI_THREADS=1
# uWSGI static file serving configuration (customize, or comment out if using Whitenoise or S3):
# ENV UWSGI_STATIC_MAP="/static/=/code/staticfiles/" UWSGI_STATIC_EXPIRES_URI="/static/.*\.[a-f0-9]{12,}\.(css|js|png|jpg|jpeg|gif|ico|woff|ttf|otf|svg|scss|map|txt) 315360000"
ENV UWSGI_STATIC_MAP="/static/=/code/staticfiles/" UWSGI_STATIC_EXPIRES_URI="/static/.*\.[a-f0-9]{12,}\.(css|js|png|jpg|jpeg|gif|ico|woff|ttf|otf|svg|scss|pdf|map|txt) 86400"
ENV UWSGI_STATIC_MAP="/media/=/code/media/" UWSGI_STATIC_EXPIRES_URI="/media/.*/.*/.*\.[a-f0-9]{12,}\.(png|jpg|jpeg|gif|svg) 3600"
# Deny invalid hosts before they get to Django (uncomment and change to your hostname(s)):
# ENV UWSGI_ROUTE_HOST="^(?!localhost:8000$) break:400"
......
......@@ -16,7 +16,6 @@ cx-oracle = "*"
django-crispy-forms = "==1.7.2"
django-summernote = "*"
django-templated-email = "*"
whitenoise = "*"
[requires]
python_version = "3.7"
{
"_meta": {
"hash": {
"sha256": "888efd2bcd3af735982120a9303ab167129eb5e4a2654869288a03f83dfa3325"
"sha256": "e25a68be8096981cc725027486facee2322a8f2a10c02c93e1616a4f14f06273"
},
"pipfile-spec": 6,
"requires": {
......@@ -249,14 +249,6 @@
],
"version": "==1.25.3"
},
"whitenoise": {
"hashes": [
"sha256:118ab3e5f815d380171b100b05b76de2a07612f422368a201a9ffdeefb2251c1",
"sha256:42133ddd5229eeb6a0c9899496bdbe56c292394bf8666da77deeb27454c0456a"
],
"index": "pypi",
"version": "==4.1.2"
},
"xmlsec": {
"hashes": [
"sha256:e573c0172174973223d874ffd158ecd4e0faa761015474385289a6468dd29ed6"
......
......@@ -34,7 +34,7 @@ pipenv --python 3.7 install --dev
Configuración inicial
---------------------
1. Configurar la base de datos en la sección `DATABASES` de `manhattan_project/settings.py`.
1. Configurar las bases de datos en el fichero `.env` y la sección `DATABASES` de `manhattan_project/settings.py`.
2. Configurar los datos para el correo, y la URL del sitio.
3. Configurar los datos para el _Single Sign On_ (SAML).
4. Ejecutar
......
version: "3.7"
services:
web:
build:
context: .
dockerfile: Dockerfile
command: uwsgi
env_file: .env
ports:
- protocol: tcp
published: 8000
target: 8000
restart: on-failure
volumes:
- ./media:/code/media:rw
......@@ -21,10 +21,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "xk6ujnt_zj7xlnt@c&$jc9f_=u3io5e!87imbqz4)=li*$tu%w"
SECRET_KEY = os.environ.get(
"DJANGO_SECRET_KEY", "xk6ujnt_zj7xlnt@c&$jc9f_=u3io5e!87imbqz4)=li*$tu%w"
)
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = os.environ.get("DEBUG", False) == "True"
ALLOWED_HOSTS = [] # ['*']
......@@ -99,10 +101,10 @@ WSGI_APPLICATION = "manhattan_project.wsgi.application"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql", # Database engine
"NAME": "manhattan", # Database name
"USER": "albert", # Database user
"PASSWORD": "einstein", # Database password
"HOST": "", # Set to empty string for localhost.
"NAME": os.environ.get("DB_NAME"), # Database name
"USER": os.environ.get("DB_USER"), # Database user
"PASSWORD": os.environ.get("DB_PASSWORD"), # Database password
"HOST": os.environ.get("DB_HOST"), # Set to empty string for localhost.
"PORT": "", # Set to empty string for default.
# Additional database options
"OPTIONS": {
......@@ -154,8 +156,10 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "/static/"
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
AUTH_USER_MODEL = "accounts.CustomUser"
LOGIN_REDIRECT_URL = "proyectos_usuario_list"
......@@ -227,7 +231,7 @@ CRISPY_TEMPLATE_PACK = "bootstrap4"
# SUMMERNOTE
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
SUMMERNOTE_THEME = "bs4"
SUMMERNOTE_CONFIG = {
......
......@@ -25,5 +25,4 @@ social-auth-app-django==3.1.0
social-auth-core[saml]==3.1.0
sqlparse==0.3.0
urllib3==1.25.3
whitenoise==4.1.2
xmlsec==1.3.3
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment