From b7efae61c47acb914230541ba3b77466787ad5c8 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Thu, 6 Nov 2025 13:46:19 +0100 Subject: [PATCH] docs --- apps/abstraction/README.md | 35 +++++++++++++++++++++++++++++++++++ apps/api/Dockerfile | 5 ----- apps/api/README.md | 35 ++++++++++++++++++++++++++++++++++- apps/simulator/Dockerfile | 5 ----- apps/simulator/README.md | 38 +++++++++++++++++++++++++++++++++----- apps/ui/README.md | 26 ++++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 16 deletions(-) diff --git a/apps/abstraction/README.md b/apps/abstraction/README.md index 22ed96f..33d51e2 100644 --- a/apps/abstraction/README.md +++ b/apps/abstraction/README.md @@ -12,11 +12,46 @@ The abstraction layer is an asyncio-based worker that manages device communicati ## Running +### Local Development + ```bash # Start the abstraction worker poetry run python -m apps.abstraction.main ``` +### Docker Container + +#### Build Image + +```bash +docker build -t abstraction:dev -f apps/abstraction/Dockerfile . +``` + +#### Run Container + +```bash +docker run --rm \ + -v $(pwd)/config:/app/config:ro \ + -e MQTT_BROKER=172.16.2.16 \ + -e MQTT_PORT=1883 \ + -e REDIS_HOST=172.23.1.116 \ + -e REDIS_PORT=6379 \ + -e REDIS_DB=8 \ + abstraction:dev +``` + +#### Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP | +| `MQTT_PORT` | `1883` | MQTT broker port | +| `REDIS_HOST` | `localhost` | Redis server hostname/IP | +| `REDIS_PORT` | `6379` | Redis server port | +| `REDIS_DB` | `0` | Redis database number | + +### What the Worker Does + The worker will: 1. Load configuration from `config/devices.yaml` 2. Connect to MQTT broker (172.16.2.16:1883) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 2a41b7f..57addcf 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -22,7 +22,6 @@ WORKDIR /app # Install system dependencies RUN apk add --no-cache \ - curl \ gcc \ musl-dev \ linux-headers @@ -42,10 +41,6 @@ RUN chown -R app:app /app # Switch to non-root user USER app -# Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:8001/health || exit 1 - # Expose port EXPOSE 8001 diff --git a/apps/api/README.md b/apps/api/README.md index 22a7ba5..5edff04 100644 --- a/apps/api/README.md +++ b/apps/api/README.md @@ -20,7 +20,7 @@ poetry run uvicorn apps.api.main:app --reload ### Production Mode ```bash -poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000 +poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8001 ``` ### Using Python directly @@ -29,6 +29,39 @@ poetry run uvicorn apps.api.main:app --host 0.0.0.0 --port 8000 poetry run python -m apps.api.main ``` +### Docker Container + +#### Build Image + +```bash +docker build -t api:dev -f apps/api/Dockerfile . +``` + +#### Run Container + +```bash +docker run --rm -p 8001:8001 \ + -v $(pwd)/config:/app/config:ro \ + -e MQTT_BROKER=172.16.2.16 \ + -e MQTT_PORT=1883 \ + -e REDIS_HOST=172.23.1.116 \ + -e REDIS_PORT=6379 \ + -e REDIS_DB=8 \ + -e REDIS_CHANNEL=ui:updates \ + api:dev +``` + +#### Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP | +| `MQTT_PORT` | `1883` | MQTT broker port | +| `REDIS_HOST` | `localhost` | Redis server hostname/IP | +| `REDIS_PORT` | `6379` | Redis server port | +| `REDIS_DB` | `0` | Redis database number | +| `REDIS_CHANNEL` | `ui:updates` | Redis pub/sub channel | + ## API Endpoints ### `GET /health` diff --git a/apps/simulator/Dockerfile b/apps/simulator/Dockerfile index 57c8fa0..2495c96 100644 --- a/apps/simulator/Dockerfile +++ b/apps/simulator/Dockerfile @@ -19,7 +19,6 @@ WORKDIR /app # Install system dependencies RUN apk add --no-cache \ - curl \ gcc \ musl-dev \ linux-headers @@ -38,10 +37,6 @@ RUN chown -R app:app /app # Switch to non-root user USER app -# Health check -HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:8010/health || exit 1 - # Expose port EXPOSE 8010 diff --git a/apps/simulator/README.md b/apps/simulator/README.md index 1f05286..4fd1147 100644 --- a/apps/simulator/README.md +++ b/apps/simulator/README.md @@ -28,22 +28,50 @@ Der Simulator ist bereits Teil des Projekts. Keine zusätzlichen Dependencies er ## Start +### Local Development + ```bash -# Standard-Start (Port 8003) -poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003 +# Standard-Start (Port 8010) +poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010 # Mit Auto-Reload für Entwicklung -poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003 --reload +poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010 --reload # Im Hintergrund -poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8003 > /tmp/simulator.log 2>&1 & +poetry run uvicorn apps.simulator.main:app --host 0.0.0.0 --port 8010 > /tmp/simulator.log 2>&1 & ``` +### Docker Container + +#### Build Image + +```bash +docker build -t simulator:dev -f apps/simulator/Dockerfile . +``` + +#### Run Container + +```bash +docker run --rm -p 8010:8010 \ + -e MQTT_BROKER=172.16.2.16 \ + -e MQTT_PORT=1883 \ + -e SIM_PORT=8010 \ + simulator:dev +``` + +#### Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `MQTT_BROKER` | `172.16.2.16` | MQTT broker hostname/IP | +| `MQTT_PORT` | `1883` | MQTT broker port | +| `SIM_PORT` | `8010` | Port for web interface | + ## Web-Interface Öffne im Browser: ``` -http://localhost:8003 +http://localhost:8010 ``` ### Features im Dashboard diff --git a/apps/ui/README.md b/apps/ui/README.md index a03dd3c..3cb389b 100644 --- a/apps/ui/README.md +++ b/apps/ui/README.md @@ -27,6 +27,32 @@ poetry run uvicorn apps.ui.main:app --reload --port 8002 poetry run python -m apps.ui.main ``` +### Docker Container + +#### Build Image + +```bash +docker build -t ui:dev -f apps/ui/Dockerfile . +``` + +#### Run Container + +```bash +docker run --rm -p 8002:8002 \ + -e UI_PORT=8002 \ + -e API_BASE=http://localhost:8001 \ + -e BASE_PATH=/ \ + ui:dev +``` + +#### Environment Variables + +| Variable | Default | Description | +|----------|---------|-------------| +| `UI_PORT` | `8002` | Port for UI server | +| `API_BASE` | `http://localhost:8001` | Base URL for API service | +| `BASE_PATH` | `/` | Base path for routing | + ## Project Structure ```