Commit 4386b93b authored by Gezer's avatar Gezer
Browse files

Added influx and mqtt config files and modified

compose.yaml but still need to fix and modify
dockerfile in stream_processing
No related merge requests found
Showing with 116 additions and 12 deletions
+116 -12
...@@ -10,7 +10,7 @@ COPY uv.lock . ...@@ -10,7 +10,7 @@ COPY uv.lock .
# Kopiere auch requirements.txt, falls vorhanden # Kopiere auch requirements.txt, falls vorhanden
COPY requirements.txt . COPY requirements.txt .
# Nutze uv
# Installiere uv und die Abhängigkeiten # Installiere uv und die Abhängigkeiten
RUN pip install --upgrade pip && \ RUN pip install --upgrade pip && \
pip install uv && \ pip install uv && \
......
django>=5.2 django>=5.2
django-cors-headers>=4.7.0 django-cors-headers>=4.7.0
influxdb-client>=1.40 influxdb-client>=1.40
\ No newline at end of file python-dotenv>=1.1
\ No newline at end of file
# 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"]
import json import json
import os import os
def load_json(file_name: str) -> dict: def load_json(file_name: str) -> dict:
""" """
ladet eine JSON Datei, wenn diese existiert, ladet eine JSON Datei, wenn diese existiert,
...@@ -14,7 +13,6 @@ def load_json(file_name: str) -> dict: ...@@ -14,7 +13,6 @@ def load_json(file_name: str) -> dict:
mac_room_mapping = json.load(f) mac_room_mapping = json.load(f)
return mac_room_mapping return mac_room_mapping
def write_json(mac_room_mapping: dict, file_name: str): def write_json(mac_room_mapping: dict, file_name: str):
""" """
Nimmt ein dictionary und schreibt dessen Nimmt ein dictionary und schreibt dessen
......
services: services:
mqtt-backend: stream-processing:
image: mqtt-influx-backend image: stream-processing
container_name: mqtt-backend container_name: stream-processing
build: ./mqtt build: ./backend/stream_processing
command: uv run -m mqtt_influx_backend.main command: uv run -m backend.stream_processing.main
env_file: env_file:
- ../mqtt_to_influxdb/.env - ../backend/.env
restart: unless-stopped restart: unless-stopped
#depends_on: #depends_on:
# - influxdb # - influxdb
# - mosquitto # - mosquitto
backend: backend:
image: django-backend
container_name: django-backend
build: ./backend build: ./backend
ports: ports:
- "8000:8000" - "8000:8000"
volumes: volumes: # was ist volumes
- ./backend:/app - ./backend:/app
frontend: frontend:
......
# frontend/Dockerfile # frontend/Dockerfile
FROM node:20 FROM node:latest
WORKDIR /app WORKDIR /app
# Nur lokale Abhängigkeiten, kein globales Vite! # Nur lokale Abhängigkeiten, kein globales Vite!
......
# 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:
password
MyInitialAdminToken0==
admin
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
listener 1883
listener 8883
listener 9001
protocol websockets
persistence true
persistence_file mosquitto.db
persistence_location /mosquitto/data/
allow_anonymous true
File added
Supports Markdown
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