diff --git a/backend/Dockerfile b/backend/Dockerfile index 6d0556067a3d3f3aac08f1645ae679c46aade1d9..100e143c2cc7452546b11468d95c5f4084afd7f1 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -10,7 +10,7 @@ COPY uv.lock . # Kopiere auch requirements.txt, falls vorhanden COPY requirements.txt . - +# Nutze uv # Installiere uv und die Abhängigkeiten RUN pip install --upgrade pip && \ pip install uv && \ diff --git a/backend/requirements.txt b/backend/requirements.txt index 5d7849df15ff0b27241d9258ea9afa7af2321690..338f007c97587a6e6129efcffb916f8ea64d88c3 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -1,3 +1,4 @@ django>=5.2 django-cors-headers>=4.7.0 -influxdb-client>=1.40 \ No newline at end of file +influxdb-client>=1.40 +python-dotenv>=1.1 \ No newline at end of file diff --git a/backend/stream_processing/Dockerfile b/backend/stream_processing/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..100e143c2cc7452546b11468d95c5f4084afd7f1 --- /dev/null +++ b/backend/stream_processing/Dockerfile @@ -0,0 +1,29 @@ +# Verwende das neueste Python-Image +FROM python:latest + +# Setze das Arbeitsverzeichnis im Container +WORKDIR /app + +# Kopiere die pyproject.toml und uv.lock-Dateien +COPY pyproject.toml . +COPY uv.lock . + +# Kopiere auch requirements.txt, falls vorhanden +COPY requirements.txt . +# Nutze uv +# Installiere uv und die Abhängigkeiten +RUN pip install --upgrade pip && \ + pip install uv && \ + pip install --no-cache-dir -r requirements.txt + +# Kopiere den Rest des Projekts in den Container +COPY . . + +# Setze Umgebungsvariablen, falls nötig +ENV PYTHONUNBUFFERED 1 + +# Exponiere den Port 8000 für den Server +EXPOSE 8000 + +# Der Startbefehl: Starte den Server mit uv +CMD ["uv", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"] diff --git a/backend/stream_processing/jsonhandler.py b/backend/stream_processing/jsonhandler.py index 8be10f99e3f4dea04307d7b3d5d8d961773bef4b..d90ba36ca8d631e91f4e590796043555672eb0e4 100644 --- a/backend/stream_processing/jsonhandler.py +++ b/backend/stream_processing/jsonhandler.py @@ -1,7 +1,6 @@ import json import os - def load_json(file_name: str) -> dict: """ ladet eine JSON Datei, wenn diese existiert, @@ -14,7 +13,6 @@ def load_json(file_name: str) -> dict: mac_room_mapping = json.load(f) return mac_room_mapping - def write_json(mac_room_mapping: dict, file_name: str): """ Nimmt ein dictionary und schreibt dessen diff --git a/docker-compose.yaml b/docker-compose.yaml index 39150fa4babbb831f34589d7fdda62efb1e2fd42..1294bb0961adbe9ad94f7f3fb1a664d9acbf38dc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,23 +1,25 @@ services: - mqtt-backend: - image: mqtt-influx-backend - container_name: mqtt-backend - build: ./mqtt - command: uv run -m mqtt_influx_backend.main + stream-processing: + image: stream-processing + container_name: stream-processing + build: ./backend/stream_processing + command: uv run -m backend.stream_processing.main env_file: - - ../mqtt_to_influxdb/.env + - ../backend/.env restart: unless-stopped #depends_on: # - influxdb # - mosquitto backend: + image: django-backend + container_name: django-backend build: ./backend ports: - "8000:8000" - volumes: + volumes: # was ist volumes - ./backend:/app frontend: diff --git a/frontend/Dockerfile b/frontend/Dockerfile index f687c9bcb1a05b5d2655156a8e3b1dff6ba65fba..dba6e6f0d664ca730c7e0d97f746c948501d0ba7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,6 +1,6 @@ # frontend/Dockerfile -FROM node:20 +FROM node:latest WORKDIR /app # Nur lokale Abhängigkeiten, kein globales Vite! diff --git a/services/influxdb/compose.yaml b/services/influxdb/compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..cf6baeebf72bbaf8715975483d54e88ad35b3c16 --- /dev/null +++ b/services/influxdb/compose.yaml @@ -0,0 +1,35 @@ +# compose.yaml +services: + influxdb2: + image: influxdb:2 + ports: + - 8086:8086 + environment: + DOCKER_INFLUXDB_INIT_MODE: setup + DOCKER_INFLUXDB_INIT_USERNAME_FILE: /run/secrets/influxdb2-admin-username + DOCKER_INFLUXDB_INIT_PASSWORD_FILE: /run/secrets/influxdb2-admin-password + DOCKER_INFLUXDB_INIT_ADMIN_TOKEN_FILE: /run/secrets/influxdb2-admin-token + DOCKER_INFLUXDB_INIT_ORG: docs + DOCKER_INFLUXDB_INIT_BUCKET: home + secrets: + - influxdb2-admin-username + - influxdb2-admin-password + - influxdb2-admin-token + volumes: + - type: volume + source: influxdb2-data + target: /var/lib/influxdb2 + - type: volume + source: influxdb2-config + target: /etc/influxdb2 +secrets: + influxdb2-admin-username: + file: /opt/stacks/influxdb/influxdb2-admin-username + influxdb2-admin-password: + file: /opt/stacks/influxdb/influxdb2-admin-password + influxdb2-admin-token: + file: /opt/stacks/influxdb/influxdb2-admin-token +volumes: + influxdb2-data: + influxdb2-config: + diff --git a/services/influxdb/influxdb2-admin-password b/services/influxdb/influxdb2-admin-password new file mode 100644 index 0000000000000000000000000000000000000000..f3097ab13082b70f67202aab7dd9d1b35b7ceac2 --- /dev/null +++ b/services/influxdb/influxdb2-admin-password @@ -0,0 +1 @@ +password diff --git a/services/influxdb/influxdb2-admin-token b/services/influxdb/influxdb2-admin-token new file mode 100644 index 0000000000000000000000000000000000000000..dd9fb541a73a74caae14360280eef26790d9be64 --- /dev/null +++ b/services/influxdb/influxdb2-admin-token @@ -0,0 +1 @@ +MyInitialAdminToken0== diff --git a/services/influxdb/influxdb2-admin-username b/services/influxdb/influxdb2-admin-username new file mode 100644 index 0000000000000000000000000000000000000000..7fbe952b76a23b08b5c0de1a519d416ada70765c --- /dev/null +++ b/services/influxdb/influxdb2-admin-username @@ -0,0 +1 @@ +admin diff --git a/services/mqtt/compose.yaml b/services/mqtt/compose.yaml new file mode 100644 index 0000000000000000000000000000000000000000..421cc24dd94388685996ca7a1d85e26a092536a0 --- /dev/null +++ b/services/mqtt/compose.yaml @@ -0,0 +1,25 @@ + +services: + mosquitto: + image: eclipse-mosquitto + container_name: mosquitto-broker + volumes: + - ./config:/mosquitto/config + - ./data:/mosquitto/data + - ./log:/mosquitto/log + - ./mosquitto:/mosquitto + ports: + - 8883:8883 + - 1883:1883 + - 9001:9001 # optional für Websockets + stdin_open: true + tty: true + + # backend: + # build: ./backend + # container_name: backend-app + # ports: + # - "3000:3000" + # depends_on: + # - mosquitto + # restart: unless-stopped diff --git a/services/mqtt/config/mosquitto.conf b/services/mqtt/config/mosquitto.conf new file mode 100644 index 0000000000000000000000000000000000000000..00df46d0d0cf7ae1e9458a7dd37aecd24030bfa5 --- /dev/null +++ b/services/mqtt/config/mosquitto.conf @@ -0,0 +1,11 @@ +listener 1883 +listener 8883 + +listener 9001 +protocol websockets + +persistence true +persistence_file mosquitto.db +persistence_location /mosquitto/data/ + +allow_anonymous true diff --git a/services/mqtt/data/mosquitto.db b/services/mqtt/data/mosquitto.db new file mode 100644 index 0000000000000000000000000000000000000000..41467253721ad106db189693a6f4d2a96e3c238d Binary files /dev/null and b/services/mqtt/data/mosquitto.db differ