Compare commits
4 Commits
2399ca9bf9
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9863807ad6 | |||
| 62e02d745f | |||
| 1a9de7f874 | |||
| 46b66eb95d |
36
Dockerfile
36
Dockerfile
@@ -1,36 +0,0 @@
|
|||||||
# Nutze ein schlankes Python-Image
|
|
||||||
FROM python:3.11-slim-bullseye
|
|
||||||
|
|
||||||
ENV PYTHONUNBUFFERED 1
|
|
||||||
|
|
||||||
WORKDIR /konova
|
|
||||||
|
|
||||||
# Installiere System-Abhängigkeiten
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
gdal-bin redis-server nginx \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* # Platz sparen
|
|
||||||
|
|
||||||
# Erstelle benötigte Verzeichnisse & setze Berechtigungen
|
|
||||||
RUN mkdir -p /var/log/nginx /var/log/gunicorn /var/lib/nginx /tmp/nginx_client_body \
|
|
||||||
&& touch /var/log/nginx/access.log /var/log/nginx/error.log \
|
|
||||||
&& chown -R root:root /var/log/nginx /var/lib/nginx /tmp/nginx_client_body
|
|
||||||
|
|
||||||
# Kopiere und installiere Python-Abhängigkeiten
|
|
||||||
COPY ./requirements.txt /konova/
|
|
||||||
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
|
|
||||||
|
|
||||||
# Entferne Standard-Nginx-Site und ersetze sie durch eigene Config
|
|
||||||
RUN rm -rf /etc/nginx/sites-enabled/default
|
|
||||||
COPY ./nginx.conf /etc/nginx/conf.d
|
|
||||||
|
|
||||||
# Kopiere restliche Projektdateien
|
|
||||||
COPY . /konova/
|
|
||||||
|
|
||||||
# Sammle statische Dateien
|
|
||||||
RUN python manage.py collectstatic --noinput
|
|
||||||
|
|
||||||
# Exponiere Ports
|
|
||||||
#EXPOSE 80 6379 8000
|
|
||||||
|
|
||||||
# Setze Entrypoint
|
|
||||||
ENTRYPOINT ["/konova/docker-entrypoint.sh"]
|
|
||||||
56
README.md
56
README.md
@@ -4,7 +4,6 @@ the database postgresql and the css library bootstrap as well as the icon packag
|
|||||||
fontawesome for a modern look, following best practices from the industry.
|
fontawesome for a modern look, following best practices from the industry.
|
||||||
|
|
||||||
## Background processes
|
## Background processes
|
||||||
### !!! For non-docker run
|
|
||||||
Konova uses celery for background processing. To start the worker you need to run
|
Konova uses celery for background processing. To start the worker you need to run
|
||||||
```shell
|
```shell
|
||||||
$ celery -A konova worker -l INFO
|
$ celery -A konova worker -l INFO
|
||||||
@@ -19,58 +18,3 @@ Technical documention is provided in the projects git wiki.
|
|||||||
A user documentation is not available (and not needed, yet).
|
A user documentation is not available (and not needed, yet).
|
||||||
|
|
||||||
|
|
||||||
# Docker
|
|
||||||
To run the docker-compose as expected, you need to take the following steps:
|
|
||||||
|
|
||||||
1. Create a database containing docker, using an appropriate Dockerfile, e.g. the following
|
|
||||||
```
|
|
||||||
version: '3.3'
|
|
||||||
services:
|
|
||||||
postgis:
|
|
||||||
image: postgis/postgis
|
|
||||||
restart: always
|
|
||||||
container_name: postgis-docker
|
|
||||||
ports:
|
|
||||||
- 5433:5432
|
|
||||||
volumes:
|
|
||||||
- db-volume:/var/lib/postgresql/data
|
|
||||||
environment:
|
|
||||||
- POSTGRES_PASSWORD=postgres
|
|
||||||
- POSTGRES_USER=postgres
|
|
||||||
networks:
|
|
||||||
- db-network-bridge
|
|
||||||
|
|
||||||
networks:
|
|
||||||
db-network-bridge:
|
|
||||||
driver: "bridge"
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
db-volume:
|
|
||||||
```
|
|
||||||
This Dockerfile creates a Docker container running postgresql and postgis, creates the default superuser postgres,
|
|
||||||
creates a named volume for persisting the database and creates a new network bridge, which **must be used by any other
|
|
||||||
container, which wants to write/read on this database**.
|
|
||||||
|
|
||||||
2. Make sure the name of the network bridge above matches the network in the konova docker-compose.yml
|
|
||||||
3. Get into the running postgis container (`docker exec -it postgis-docker bash`) and create new databases, users and so on. Make sure the database `konova` exists now!
|
|
||||||
4. Replace all `CHANGE_ME_xy` values inside of konova/docker-compose.yml for your installation. Make sure the `SSO_HOST` holds the proper SSO host, e.g. for the arnova project `arnova.example.org` (Arnova must be installed and the webserver configured as well, of course)
|
|
||||||
5. Take a look on konova/settings.py and konova/sub_settings/django_settings.py. Again: Replace all occurences of `CHANGE_ME` with proper values for your installation.
|
|
||||||
1. Make sure you have the proper host strings added to `ALLOWED_HOSTS` inside of django_settings.py.
|
|
||||||
6. Build and run the docker setup using `docker-compose build` and `docker-compose start` from the main directory of this project (where the docker-compose.yml lives)
|
|
||||||
7. Run migrations! To do so, get into the konova service container (`docker exec -it konova-docker bash`) and run the needed commands (`python manage.py makemigrations LIST_OF_ALL_MIGRATABLE_APPS`, then `python manage.py migrate`)
|
|
||||||
8. Run the setup command `python manage.py setup` and follow the instructions on the CLI
|
|
||||||
9. To enable **SMTP** mail support, make sure your host machine (the one where the docker container run) has the postfix service configured properly. Make sure the `mynetworks` variable is xtended using the docker network bridge ip, created in the postgis container and used by the konova services.
|
|
||||||
1. **Hint**: You can find out this easily by trying to perform a test mail in the running konova web application (which will fail, of course). Then take a look to the latest entries in `/var/log/mail.log` on your host machine. The failed IP will be displayed there.
|
|
||||||
2. **Please note**: This installation guide is based on SMTP using postfix!
|
|
||||||
3. Restart the postfix service on your host machine to reload the new configuration (`service postfix restart`)
|
|
||||||
10. Finally, make sure your host machine webserver passes incoming requests properly to the docker nginx webserver of konova. A proper nginx config for the host machine may look like this:
|
|
||||||
```
|
|
||||||
server {
|
|
||||||
server_name konova.domain.org;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:KONOVA_NGINX_DOCKER_PORT/;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -124,7 +124,7 @@ class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
html += self.render_previously_checked_star(
|
html += self.render_previously_checked_star(
|
||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
def render_r(self, value, record: Compensation):
|
def render_r(self, value, record: Compensation):
|
||||||
""" Renders the registered column for a compensation
|
""" Renders the registered column for a compensation
|
||||||
@@ -146,5 +146,5 @@ class CompensationTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
icn_filled=recorded,
|
icn_filled=recorded,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
txt=value,
|
txt=value,
|
||||||
new_tab=False,
|
new_tab=False,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
def render_av(self, value, record: EcoAccount):
|
def render_av(self, value, record: EcoAccount):
|
||||||
""" Renders the available column for an eco account
|
""" Renders the available column for an eco account
|
||||||
@@ -113,7 +113,7 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
value_relative = 0
|
value_relative = 0
|
||||||
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
html = render_to_string("konova/widgets/progressbar.html", {"value": value_relative})
|
||||||
html += f"{number_format(record.deductable_rest, decimal_pos=2)} m²"
|
html += f"{number_format(record.deductable_rest, decimal_pos=2)} m²"
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
def render_r(self, value, record: EcoAccount):
|
def render_r(self, value, record: EcoAccount):
|
||||||
""" Renders the recorded column for an eco account
|
""" Renders the recorded column for an eco account
|
||||||
@@ -135,4 +135,4 @@ class EcoAccountTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
icn_filled=checked,
|
icn_filled=checked,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
services:
|
|
||||||
konova:
|
|
||||||
external_links:
|
|
||||||
- postgis:db
|
|
||||||
- arnova-nginx-server:arnova
|
|
||||||
build: .
|
|
||||||
image: "ksp/konova:x.y"
|
|
||||||
container_name: "konova-docker"
|
|
||||||
command: ./docker-entrypoint.sh
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- /data/apps/konova/uploaded_files:/konova_uploaded_files
|
|
||||||
ports:
|
|
||||||
- "1337:80"
|
|
||||||
|
|
||||||
# Instead of an own, new network, we need to connect to the existing one, which is provided by the postgis container
|
|
||||||
# NOTE: THIS NETWORK MUST EXIST
|
|
||||||
networks:
|
|
||||||
default:
|
|
||||||
name: postgis_nat_it_backend
|
|
||||||
external: true
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e # Beende Skript bei Fehlern
|
|
||||||
set -o pipefail # Fehler in Pipelines nicht ignorieren
|
|
||||||
|
|
||||||
# Starte Redis
|
|
||||||
redis-server --daemonize yes
|
|
||||||
|
|
||||||
# Starte Celery Worker im Hintergrund
|
|
||||||
celery -A konova worker --loglevel=info &
|
|
||||||
|
|
||||||
# Starte Nginx als Hintergrundprozess
|
|
||||||
nginx -g "daemon off;" &
|
|
||||||
|
|
||||||
# Setze Gunicorn Worker-Anzahl (Standard: (2*CPUs)+1)
|
|
||||||
WORKERS=${GUNICORN_WORKERS:-$((2 * $(nproc) + 1))}
|
|
||||||
|
|
||||||
# Stelle sicher, dass Logs existieren
|
|
||||||
mkdir -p /var/log/gunicorn
|
|
||||||
touch /var/log/gunicorn/access.log /var/log/gunicorn/error.log
|
|
||||||
|
|
||||||
# Starte Gunicorn als Hauptprozess
|
|
||||||
exec gunicorn --workers="$WORKERS" konova.wsgi:application \
|
|
||||||
--bind=0.0.0.0:8000 \
|
|
||||||
--access-logfile /var/log/gunicorn/access.log \
|
|
||||||
--error-logfile /var/log/gunicorn/error.log \
|
|
||||||
--access-logformat '%({x-real-ip}i)s via %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
|
|
||||||
@@ -88,7 +88,7 @@ class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
txt=value,
|
txt=value,
|
||||||
new_tab=False,
|
new_tab=False,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
def render_r(self, value, record: Ema):
|
def render_r(self, value, record: Ema):
|
||||||
""" Renders the registered column for a EMA
|
""" Renders the registered column for a EMA
|
||||||
@@ -110,4 +110,4 @@ class EmaTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
icn_filled=recorded,
|
icn_filled=recorded,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
html += self.render_previously_checked_star(
|
html += self.render_previously_checked_star(
|
||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
def render_r(self, value, record: Intervention):
|
def render_r(self, value, record: Intervention):
|
||||||
""" Renders the recorded column for an intervention
|
""" Renders the recorded column for an intervention
|
||||||
@@ -149,5 +149,5 @@ class InterventionTable(BaseTable, TableRenderMixin, TableOrderMixin):
|
|||||||
tooltip=tooltip,
|
tooltip=tooltip,
|
||||||
icn_filled=checked,
|
icn_filled=checked,
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
|
|||||||
@@ -191,10 +191,11 @@ STATICFILES_DIRS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# EMAIL (see https://docs.djangoproject.com/en/dev/topics/email/)
|
# EMAIL (see https://docs.djangoproject.com/en/dev/topics/email/)
|
||||||
|
|
||||||
|
# CHANGE_ME !!! ONLY FOR DEVELOPMENT !!!
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
# ONLY FOR DEVELOPMENT NEEDED
|
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
|
||||||
EMAIL_FILE_PATH = '/tmp/app-messages'
|
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location
|
||||||
|
|
||||||
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL") # The default email address for the 'from' element
|
DEFAULT_FROM_EMAIL = env("DEFAULT_FROM_EMAIL") # The default email address for the 'from' element
|
||||||
SERVER_EMAIL = DEFAULT_FROM_EMAIL # The default email sender address, which is used by Django to send errors via mail
|
SERVER_EMAIL = DEFAULT_FROM_EMAIL # The default email sender address, which is used by Django to send errors via mail
|
||||||
|
|||||||
@@ -30,15 +30,17 @@ class QrCode:
|
|||||||
Returns:
|
Returns:
|
||||||
qrcode_svg (str): The qr code as svg
|
qrcode_svg (str): The qr code as svg
|
||||||
"""
|
"""
|
||||||
img_factory = svg.SvgImage
|
qr = qrcode.QRCode(
|
||||||
qrcode_img = qrcode.make(
|
image_factory=qrcode.image.svg.SvgPathImage,
|
||||||
content,
|
|
||||||
image_factory=img_factory,
|
|
||||||
box_size=size
|
box_size=size
|
||||||
)
|
)
|
||||||
stream = BytesIO()
|
qr.add_data(content)
|
||||||
qrcode_img.save(stream)
|
qr.make(
|
||||||
return stream.getvalue().decode()
|
fit=True
|
||||||
|
)
|
||||||
|
|
||||||
|
img = qr.make_image()
|
||||||
|
return img.to_string(encoding="unicode")
|
||||||
|
|
||||||
def get_img(self):
|
def get_img(self):
|
||||||
return self._img
|
return self._img
|
||||||
|
|||||||
@@ -178,7 +178,9 @@ class TableRenderMixin:
|
|||||||
if len(value) > max_length:
|
if len(value) > max_length:
|
||||||
value = f"{value[:max_length]}..."
|
value = f"{value[:max_length]}..."
|
||||||
value = format_html(
|
value = format_html(
|
||||||
f'<div title="{value_orig}">{value}</div>'
|
'<div title="{}">{}</div>',
|
||||||
|
value_orig,
|
||||||
|
value
|
||||||
)
|
)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@@ -222,7 +224,7 @@ class TableRenderMixin:
|
|||||||
tooltip=_("Full access granted") if is_entry_shared else _("Access not granted"),
|
tooltip=_("Full access granted") if is_entry_shared else _("Access not granted"),
|
||||||
icn_class="fas fa-edit rlp-r-inv" if is_entry_shared else "far fa-edit",
|
icn_class="fas fa-edit rlp-r-inv" if is_entry_shared else "far fa-edit",
|
||||||
)
|
)
|
||||||
return format_html(html)
|
return format_html(html, None)
|
||||||
|
|
||||||
|
|
||||||
class TableOrderMixin:
|
class TableOrderMixin:
|
||||||
|
|||||||
25
nginx.conf
25
nginx.conf
@@ -1,25 +0,0 @@
|
|||||||
server {
|
|
||||||
listen 80;
|
|
||||||
client_max_body_size 25M;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_pass http://127.0.0.1:8000;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_cache_bypass $http_upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /static/ {
|
|
||||||
alias /konova/static/;
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
autoindex off;
|
|
||||||
types {
|
|
||||||
text/css css;
|
|
||||||
application/javascript js;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
error_log /var/log/nginx/error.log;
|
|
||||||
}
|
|
||||||
@@ -1,63 +1,65 @@
|
|||||||
amqp==5.3.1
|
amqp==5.3.1
|
||||||
asgiref==3.8.1
|
asgiref==3.11.1
|
||||||
async-timeout==5.0.1
|
async-timeout==5.0.1
|
||||||
beautifulsoup4==4.13.0b2
|
beautifulsoup4==4.14.3
|
||||||
billiard==4.2.1
|
billiard==4.2.4
|
||||||
cached-property==2.0.1
|
cached-property==2.0.1
|
||||||
celery==5.4.0
|
celery==5.6.2
|
||||||
certifi==2024.12.14
|
certifi==2026.2.25
|
||||||
cffi==1.17.1
|
cffi==2.0.0
|
||||||
chardet==5.2.0
|
chardet==6.0.0.post1
|
||||||
charset-normalizer==3.4.0
|
charset-normalizer==3.4.4
|
||||||
click==8.1.8
|
click==8.3.1
|
||||||
click-didyoumean==0.3.1
|
click-didyoumean==0.3.1
|
||||||
click-plugins==1.1.1
|
click-plugins==1.1.1.2
|
||||||
click-repl==0.3.0
|
click-repl==0.3.0
|
||||||
coverage==7.6.9
|
coverage==7.13.4
|
||||||
cryptography==44.0.0
|
cryptography==46.0.5
|
||||||
Deprecated==1.2.15
|
Deprecated==1.3.1
|
||||||
Django==5.1.4
|
Django==6.0.2
|
||||||
django-autocomplete-light==3.11.0
|
django-autocomplete-light==3.12.1
|
||||||
django-bootstrap-modal-forms==3.0.5
|
django-bootstrap-modal-forms==3.0.5
|
||||||
django-bootstrap4==24.4
|
django-bootstrap4==26.1
|
||||||
django-environ==0.11.2
|
django-environ==0.13.0
|
||||||
django-filter==24.3
|
django-filter==25.2
|
||||||
django-fontawesome-5==1.0.18
|
django-fontawesome-5==1.0.18
|
||||||
django-oauth-toolkit==3.0.1
|
django-oauth-toolkit==3.2.0
|
||||||
django-tables2==2.7.1
|
django-tables2==2.8.0
|
||||||
et_xmlfile==2.0.0
|
et_xmlfile==2.0.0
|
||||||
gunicorn==23.0.0
|
gunicorn==25.1.0
|
||||||
idna==3.10
|
idna==3.11
|
||||||
importlib_metadata==8.5.0
|
importlib_metadata==8.7.1
|
||||||
|
itsdangerous==2.2.0
|
||||||
jwcrypto==1.5.6
|
jwcrypto==1.5.6
|
||||||
kombu==5.4.0rc1
|
kombu==5.6.2
|
||||||
oauthlib==3.2.2
|
oauthlib==3.3.1
|
||||||
openpyxl==3.2.0b1
|
openpyxl==3.2.0b1
|
||||||
packaging==24.2
|
packaging==26.0
|
||||||
pika==1.3.2
|
pika==1.3.2
|
||||||
pillow==11.0.0
|
pillow==12.1.1
|
||||||
prompt_toolkit==3.0.48
|
prompt_toolkit==3.0.52
|
||||||
psycopg==3.2.3
|
psycopg==3.3.3
|
||||||
psycopg-binary==3.2.3
|
psycopg-binary==3.3.3
|
||||||
pycparser==2.22
|
pycparser==3.0
|
||||||
pyparsing==3.2.0
|
pyparsing==3.3.2
|
||||||
pypng==0.20220715.0
|
pypng==0.20220715.0
|
||||||
pyproj==3.7.0
|
pyproj==3.7.2
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
pytz==2024.2
|
pytz==2025.2
|
||||||
PyYAML==6.0.2
|
PyYAML==6.0.3
|
||||||
qrcode==7.3.1
|
qrcode==8.2
|
||||||
redis==5.1.0b6
|
redis==7.2.1
|
||||||
requests<2.32.0
|
requests==2.32.5
|
||||||
six==1.16.0
|
six==1.17.0
|
||||||
soupsieve==2.5
|
soupsieve==2.8.3
|
||||||
sqlparse==0.5.1
|
sqlparse==0.5.5
|
||||||
typing_extensions==4.12.2
|
typing_extensions==4.15.0
|
||||||
tzdata==2024.2
|
tzdata==2025.3
|
||||||
urllib3==2.3.0
|
tzlocal==5.3.1
|
||||||
|
urllib3==2.6.3
|
||||||
vine==5.1.0
|
vine==5.1.0
|
||||||
wcwidth==0.2.13
|
wcwidth==0.6.0
|
||||||
webservices==0.7
|
webservices==0.7
|
||||||
wrapt==1.16.0
|
wrapt==2.1.1
|
||||||
xmltodict==0.14.2
|
xmltodict==1.0.4
|
||||||
zipp==3.21.0
|
zipp==3.23.0
|
||||||
|
|||||||
Reference in New Issue
Block a user