VERISON in Dockerfile abhandeln
This commit is contained in:
parent
58f5522442
commit
89f02422e7
@ -12,10 +12,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Set version in Cargo.toml
|
|
||||||
run: |
|
|
||||||
VERSION=$(cat VERSION)
|
|
||||||
sed -i "s/^version = \"__VERSION__\"/version = \"$VERSION\"/" Cargo.toml
|
|
||||||
- name: Build image with Podman
|
- name: Build image with Podman
|
||||||
env:
|
env:
|
||||||
BUILDAH_ISOLATION: chroot
|
BUILDAH_ISOLATION: chroot
|
||||||
|
|||||||
@ -6,11 +6,14 @@ WORKDIR /usr/src/app
|
|||||||
|
|
||||||
COPY Cargo.toml ./
|
COPY Cargo.toml ./
|
||||||
COPY Cargo.lock ./
|
COPY Cargo.lock ./
|
||||||
|
COPY VERSION ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY templates ./templates
|
COPY templates ./templates
|
||||||
COPY static ./static
|
COPY static ./static
|
||||||
|
|
||||||
RUN cargo build --release
|
RUN VERSION=$(cat VERSION) \
|
||||||
|
&& sed -i 's/^version = "__VERSION__"/version = "'"$VERSION"'"/' Cargo.toml \
|
||||||
|
&& cargo build --release
|
||||||
|
|
||||||
# Runtime Stage
|
# Runtime Stage
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
|
|||||||
189
README.md
189
README.md
@ -1,190 +1,103 @@
|
|||||||
# Tabellen Webserver
|
# Paramod
|
||||||
|
|
||||||
Ein einfacher Rust-Webserver, der eine editierbare 3x3-Tabelle bereitstellt und in einer JSON-Konfigurationsdatei persistiert.
|
Rust-Webserver zur Anzeige und Bearbeitung von Modbus-Tabellen mit Persistierung in `paramod.yaml`.
|
||||||
|
|
||||||
## Projektstruktur
|
|
||||||
|
|
||||||
```
|
|
||||||
paramod/
|
|
||||||
├── src/
|
|
||||||
│ └── main.rs
|
|
||||||
├── templates/
|
|
||||||
│ ├── index.html
|
|
||||||
│ └── settings.html
|
|
||||||
├── static/
|
|
||||||
│ ├── style.css
|
|
||||||
│ ├── script.js
|
|
||||||
│ └── settings.js
|
|
||||||
├── Cargo.toml
|
|
||||||
├── Dockerfile
|
|
||||||
├── .gitignore
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|
||||||
## Funktionen
|
## Funktionen
|
||||||
|
|
||||||
- **3 separate Tabellen** für verschiedene Sensor-Gruppen
|
- Tabellen für `modbus_input_register`, `modbus_holding_register` und `modbus_coils`
|
||||||
- **Navigation** mit aktivem Status-Indikator
|
- Web-UI zum Bearbeiten und Speichern der Tabellen
|
||||||
- **Header mit Logo** für professionelles Erscheinungsbild
|
- Einstellungsseite für `default`, `modbus`, `mqtt` und `influxdb`
|
||||||
- **Zeilen hinzufügen/löschen** dynamisch zur Laufzeit
|
- MQTT/Influx-Integration gemäß Konfiguration
|
||||||
- **Einstellungsseite** für MQTT und InfluxDB Konfiguration
|
- Speicherung aller Änderungen in `paramod.yaml`
|
||||||
- Editierbare Textfelder (Bezeichnung, Adresse, Type, Faktor)
|
|
||||||
- Toggle-Schalter für Boolean-Werte (MQTT, InfluxDB)
|
|
||||||
- **Zentrale JSON-Persistierung** für alle Tabellen und Einstellungen
|
|
||||||
- REST-API für Daten-Management
|
|
||||||
- Docker-Unterstützung
|
|
||||||
- Responsive Design
|
|
||||||
|
|
||||||
## Lokale Entwicklung
|
## Lokale Entwicklung
|
||||||
|
|
||||||
### Voraussetzungen
|
### Voraussetzungen
|
||||||
|
|
||||||
- Rust (Version 1.75 oder höher)
|
- Rust + Cargo
|
||||||
- Cargo
|
|
||||||
|
|
||||||
### Installation und Start
|
### Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Projekt erstellen
|
|
||||||
cargo new paramod
|
|
||||||
cd paramod
|
|
||||||
|
|
||||||
# Dependencies installieren und starten
|
|
||||||
cargo run
|
cargo run
|
||||||
```
|
```
|
||||||
|
|
||||||
Der Server läuft dann auf `http://localhost:8080`
|
Server: `http://localhost:8080`
|
||||||
|
|
||||||
## Docker
|
## Docker (Podman)
|
||||||
|
|
||||||
### Container bauen
|
### Image bauen
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
podman build -t paramod .
|
podman build -t paramod:latest .
|
||||||
```
|
```
|
||||||
|
|
||||||
### Container starten
|
### Container starten
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
poddman run -p 8080:8080 -v $(pwd)/data:/app/data paramod
|
podman run --rm -p 8080:8080 -v "$(pwd)/paramod.yaml:/app/paramod.yaml" paramod:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Mit Volume-Mount bleibt die Konfigurationsdatei auch nach Container-Neustarts erhalten.
|
|
||||||
|
|
||||||
## Verwendung
|
|
||||||
|
|
||||||
1. Öffne `http://localhost:8080` im Browser
|
|
||||||
2. Navigiere zwischen den Tabellen über das Menü:
|
|
||||||
- **Tabelle 1, 2, 3**: Verschiedene Sensor-Gruppen
|
|
||||||
- **⚙️ Einstellungen**: MQTT und InfluxDB Konfiguration
|
|
||||||
3. In den Tabellen:
|
|
||||||
- **➕ Zeile hinzufügen**: Neue Sensor-Einträge erstellen
|
|
||||||
- **🗑️ Löschen**: Einzelne Zeilen entfernen
|
|
||||||
- **Felder bearbeiten**:
|
|
||||||
- Bezeichnung: Name des Sensors
|
|
||||||
- Adresse: IP-Adresse oder Identifier
|
|
||||||
- Type: Sensor-Typ (z.B. Temperatur, Luftfeuchtigkeit)
|
|
||||||
- Faktor: Numerischer Korrekturfaktor
|
|
||||||
- MQTT: Toggle-Schalter für MQTT-Aktivierung
|
|
||||||
- InfluxDB: Toggle-Schalter für InfluxDB-Aktivierung
|
|
||||||
4. **💾 Speichern**: Änderungen persistieren
|
|
||||||
5. Alle Daten werden zentral in `paramod.yaml` gespeichert
|
|
||||||
|
|
||||||
## API Endpoints
|
## API Endpoints
|
||||||
|
|
||||||
- `GET /` - Zeigt Tabelle 1
|
- `GET /`
|
||||||
- `GET /table/table2` - Zeigt Tabelle 2
|
- `GET /table/modbus_input_register`
|
||||||
- `GET /table/table3` - Zeigt Tabelle 3
|
- `GET /table/modbus_holding_register`
|
||||||
- `GET /settings` - Zeigt Einstellungsseite
|
- `GET /table/modbus_coils`
|
||||||
- `POST /api/save` - Speichert eine Tabelle
|
- `GET /settings`
|
||||||
- `POST /api/save-settings` - Speichert die Einstellungen
|
- `GET /api/config`
|
||||||
- `GET /static/*` - Statische Dateien (CSS, JS)
|
- `POST /api/save`
|
||||||
|
- `POST /api/save-settings`
|
||||||
|
|
||||||
### Beispiel API-Request (Tabelle speichern)
|
## API-Beispiel: Tabelle speichern
|
||||||
|
|
||||||
|
Beispiel für Holding-Register:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X POST http://localhost:8080/api/save \
|
curl -X POST http://localhost:8080/api/save \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"table_id": "table1",
|
"table_id": "modbus_holding_register",
|
||||||
"rows": [
|
"rows": [
|
||||||
{
|
{
|
||||||
"bezeichnung": "Sensor 1",
|
"TVsoll": {
|
||||||
"adresse": "192.168.1.100",
|
"addr": 2,
|
||||||
"type": "Temperatur",
|
"type": "INT16",
|
||||||
"faktor": "1.0",
|
"factor": 0.1,
|
||||||
"mqtt": true,
|
"write": true,
|
||||||
"influxdb": false
|
"mqtt": true,
|
||||||
|
"influxdb": true,
|
||||||
|
"comment": "Vorlauf Soll"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Beispiel API-Request (Einstellungen speichern)
|
Beispiel für Coils:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X POST http://localhost:8080/api/save-settings \
|
curl -X POST http://localhost:8080/api/save \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{
|
-d '{
|
||||||
"mqtt_broker": "localhost",
|
"table_id": "modbus_coils",
|
||||||
"mqtt_port": "1883",
|
"rows": [
|
||||||
"influxdb_url": "http://localhost:8086",
|
{
|
||||||
"influxdb_token": "your-token-here"
|
"MgtSystem": {
|
||||||
|
"addr": 0,
|
||||||
|
"write": true,
|
||||||
|
"mqtt": true,
|
||||||
|
"influxdb": false,
|
||||||
|
"comment": "Leitsystem aktiv"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Konfigurationsdatei
|
## Konfiguration
|
||||||
|
|
||||||
Die komplette Anwendungskonfiguration wird in `table_config.json` gespeichert:
|
Die komplette Konfiguration liegt in `paramod.yaml`.
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"table1": [
|
|
||||||
{
|
|
||||||
"bezeichnung": "Temp Sensor 1",
|
|
||||||
"adresse": "192.168.1.100",
|
|
||||||
"type": "Temperatur",
|
|
||||||
"faktor": "1.0",
|
|
||||||
"mqtt": true,
|
|
||||||
"influxdb": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"bezeichnung": "Temp Sensor 2",
|
|
||||||
"adresse": "192.168.1.101",
|
|
||||||
"type": "Temperatur",
|
|
||||||
"faktor": "1.0",
|
|
||||||
"mqtt": false,
|
|
||||||
"influxdb": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"table2": [
|
|
||||||
{
|
|
||||||
"bezeichnung": "Humidity Sensor 1",
|
|
||||||
"adresse": "192.168.1.200",
|
|
||||||
"type": "Luftfeuchtigkeit",
|
|
||||||
"faktor": "0.5",
|
|
||||||
"mqtt": true,
|
|
||||||
"influxdb": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"table3": [
|
|
||||||
{
|
|
||||||
"bezeichnung": "Pressure Sensor 1",
|
|
||||||
"adresse": "192.168.1.300",
|
|
||||||
"type": "Druck",
|
|
||||||
"faktor": "2.0",
|
|
||||||
"mqtt": true,
|
|
||||||
"influxdb": false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"settings": {
|
|
||||||
"mqtt_broker": "localhost",
|
|
||||||
"mqtt_port": "1883",
|
|
||||||
"influxdb_url": "http://localhost:8086",
|
|
||||||
"influxdb_token": ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user