diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ca4358a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,104 @@ +#FROM python:3.10-alpine +FROM docker.io/python:3.10-slim AS base + +ENV \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + # python: + PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PYTHONDONTWRITEBYTECODE=1 + +RUN apt-get update + +RUN apt-get install -y --no-install-recommends libmagic-dev libglib2.0-dev libpango-1.0-0 libpangoft2-1.0-0 + +RUN apt-get update && \ + apt-get install -y curl gnupg && \ + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ + echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ + apt-get update && \ + apt-get install -y yarn && \ + apt-get install -y --no-install-recommends build-essential gcc && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV VIRTUAL_ENV=/venv + +# Use production configuration. +ENV DJANGO_SETTINGS_MODULE=publichealth.settings +ENV DJANGO_CONFIGURATION=production + + +### builder image + +FROM base as build + +ENV \ + # pip: + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 + +RUN python3 -m venv $VIRTUAL_ENV + +RUN mkdir -p /build/static +WORKDIR /build + +# Install python dependencies. +COPY requirements.txt requirements.txt ./ +RUN . /venv/bin/activate && pip install -r requirements.txt + +# We will run dumb-init as pid 1. +RUN . /venv/bin/activate && pip install dumb-init + +# We will run our app using gunicorn. +RUN . /venv/bin/activate && pip install gunicorn + +# Copy local code into to the build image. +COPY . /build + +# Copy code required for runtime to the /app folder. +RUN mkdir -p /app +RUN cp -r publichealth feedler yarn.lock manage.py package.json Gruntfile.js setup_libs.sh /app/ + + +#RUN curl -fsSLO https://deb.nodesource.com/setup_18.x && chmod +x setup_18.x && ./setup_18.x +#RUN apt install -y nodejs +#RUN npm install -g grunt-cli + +# Collect static data into /app/static. +#RUN . /venv/bin/activate && \ +# DJANGO_STATIC_ROOT=/app/static SECRET_KEY=sl DJANGO_SETTINGS_MODULE=publichealth.settings.production ./manage.py collectstatic --no-input -i media + +#RUN mkdir -p /app/publichealth/static/libs + +#RUN cp -rf node_modules/@bower_components/* /app/publichealth/static/libs + + +#RUN . /venv/bin/activate && \ +# DJANGO_STATIC_ROOT=/app/static SECRET_KEY=sl DJANGO_SETTINGS_MODULE=publichealth.settings.production ./manage.py compress --force + +#RUN cp -r /build/static /app/static + +### runtime image + +FROM base as runtime + +#RUN apt-get install -y --no-install-recommends libpango-1.0-0 libpangoft2-1.0-0 +#RUN apt-get install -y --no-install-recommends procps iproute2 curl + +COPY --from=build /venv /venv +COPY --from=build /app /app + +WORKDIR /app + +# Ensure exectutables from virtualenv are prefered. +ENV PATH="/venv/bin:$PATH" +ENTRYPOINT ["/venv/bin/dumb-init", "--", "gunicorn", \ + "-b [::]:8000", \ + "--log-file=-", \ + "--worker-tmp-dir", "/dev/shm", \ + "--workers=2", "--threads=4", "--worker-class=gthread"] +CMD ["publichealth.wsgi"] diff --git a/publichealth/home/templatetags/navigation.py b/publichealth/home/templatetags/navigation.py index 7082a43..9d984e9 100644 --- a/publichealth/home/templatetags/navigation.py +++ b/publichealth/home/templatetags/navigation.py @@ -54,12 +54,13 @@ def top_menu(context, parent, calling_page=None): menuitems = parent.get_children().live().in_menu().specific() for menuitem in menuitems: menuitem.show_dropdown = has_menu_children(menuitem) - menuitem.active = (calling_page.url.startswith(menuitem.url) - if calling_page else False) - try: - menuitem.title = menuitem.trans_title - except AttributeError: - pass + if calling_page: + menuitem.active = (calling_page.url.startswith(menuitem.url) + if calling_page else False) + try: + menuitem.title = menuitem.trans_title + except AttributeError: + pass return { 'calling_page': calling_page, 'menuitems': menuitems, diff --git a/publichealth/settings/production.py b/publichealth/settings/production.py index 78f27dc..56096e0 100644 --- a/publichealth/settings/production.py +++ b/publichealth/settings/production.py @@ -1,6 +1,9 @@ +import logging import os +import sys import dj_database_url +from logging.handlers import RotatingFileHandler from .base import * # Do not set SECRET_KEY, Postgres or LDAP password or any other sensitive data here. @@ -149,10 +152,19 @@ LOGGING = { 'level': 'ERROR', 'class': 'django.utils.log.AdminEmailHandler', }, + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'stream': sys.stdout, + 'formatter': 'simple', + }, }, 'formatters': { 'default': { 'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s' + }, + 'simple': { + 'verbose': '[%(asctime)s] (%(process)d/%(thread)d) %(name)s %(levelname)s: %(message)s' } }, 'loggers': { @@ -194,7 +206,7 @@ if 'LOG_DIR' in env: # Public Health Schweiz log LOGGING['handlers']['publichealth_file'] = { 'level': 'INFO', - 'class': 'cloghandler.ConcurrentRotatingFileHandler', + 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(env['LOG_DIR'], 'publichealth.log'), 'maxBytes': 5242880, # 5MB 'backupCount': 5 @@ -204,7 +216,7 @@ if 'LOG_DIR' in env: # Wagtail log LOGGING['handlers']['wagtail_file'] = { 'level': 'WARNING', - 'class': 'cloghandler.ConcurrentRotatingFileHandler', + 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(env['LOG_DIR'], 'wagtail.log'), 'maxBytes': 5242880, # 5MB 'backupCount': 5 @@ -214,7 +226,7 @@ if 'LOG_DIR' in env: # Error log LOGGING['handlers']['errors_file'] = { 'level': 'ERROR', - 'class': 'cloghandler.ConcurrentRotatingFileHandler', + 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(env['LOG_DIR'], 'error.log'), 'maxBytes': 5242880, # 5MB 'backupCount': 5 diff --git a/publichealth/static/css/subsites.scss b/publichealth/static/css/subsites.scss index b9aa5ce..df071ef 100644 --- a/publichealth/static/css/subsites.scss +++ b/publichealth/static/css/subsites.scss @@ -49,6 +49,7 @@ html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand { background-image: url('/static/org/NGO-Allianz_Logo-fr.jpg'); } + // -site-ngo-allianz-ebk // Custom styles for gesundheitsmanifest.ch @@ -61,3 +62,18 @@ html[lang='fr'] .site-ngo-allianz-ebk .navbar-brand { border-bottom: 1px solid #ddd; } } + +.site-dev-pro-salutech { + .navbar-brand { + width: 240px; + height: 64px; + background-size: contain !important; + background-repeat: no-repeat; + background-image: url('/static/images/pro-salute-logo.png'); + + font-size: 0px !important; + img { display: none !important; } + } + #carousel-banner .carousel-caption { display: none; } +} + diff --git a/publichealth/static/images/favicon-prosalute.ico b/publichealth/static/images/favicon-prosalute.ico new file mode 100644 index 0000000..7611f74 Binary files /dev/null and b/publichealth/static/images/favicon-prosalute.ico differ diff --git a/publichealth/templates/header.html b/publichealth/templates/header.html index 2f4033f..7594be0 100644 --- a/publichealth/templates/header.html +++ b/publichealth/templates/header.html @@ -2,6 +2,9 @@ {% get_site_root as site_root %} {% get_site as the_site %} + +