Anpassung Pipeline und Dockerfile

This commit is contained in:
Eric Neuber 2026-02-17 23:20:46 +01:00
parent adac95129d
commit 67b0e4ebd7
7 changed files with 68 additions and 69 deletions

View File

@ -0,0 +1,31 @@
name: Build Docker Image (Podman)
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Podman
run: sudo apt-get update && sudo apt-get install -y podman
- name: Checkout code
uses: actions/checkout@v3
- name: Set version in Cargo.toml
run: |
VERSION=$(cat VERSION)
sed -i "s/^version = \"__VERSION__\"/version = \"$VERSION\"/" Cargo.toml
- name: Build image with Podman
run: |
VERSION=$(cat VERSION)
podman build -t paramod:latest -t git.skaville.rocks/eneuber/paramod:$VERSION .
- name: Login to Gitea Registry
run: echo ${{ secrets.REGISTRY_TOKEN }} | podman login -u ${{ secrets.USER }} --password-stdin git.skaville.rocks
- name: Push image with version
run: |
VERSION=$(cat VERSION)
podman push git.skaville.rocks/eneuber/paramod:$VERSION
- name: Push image latest
run: podman push git.skaville.rocks/eneuber/paramod:latest

2
.vscode/launch.json vendored
View File

@ -5,7 +5,7 @@
"name": "Debug main.rs",
"type": "lldb",
"request": "launch",
"program": "${workspaceFolder}/target/debug/table-server",
"program": "${workspaceFolder}/target/debug/paramod",
"args": [],
"cwd": "${workspaceFolder}",
"sourceLanguages": ["rust"],

40
Cargo.lock generated
View File

@ -1317,6 +1317,26 @@ dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "paramod"
version = "0.3.0"
dependencies = [
"actix-files",
"actix-web",
"chrono",
"config",
"influxdb",
"rumqttc",
"serde",
"serde_derive",
"serde_json",
"serde_yaml",
"tera",
"tokio",
"tokio-modbus",
"toml",
]
[[package]]
name = "parking_lot"
version = "0.12.5"
@ -2050,26 +2070,6 @@ dependencies = [
"libc",
]
[[package]]
name = "table-server"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"chrono",
"config",
"influxdb",
"rumqttc",
"serde",
"serde_derive",
"serde_json",
"serde_yaml",
"tera",
"tokio",
"tokio-modbus",
"toml",
]
[[package]]
name = "tera"
version = "1.20.1"

View File

@ -1,6 +1,6 @@
[package]
name = "table-server"
version = "0.1.0"
name = "paramod"
version = "__VERSION__"
edition = "2021"
[dependencies]

View File

@ -1,44 +1,33 @@
# Build Stage
FROM rust:1.75 as builder
FROM rust:1.81 as builder
WORKDIR /usr/src/app
# Copy manifest files
COPY Cargo.toml ./
# Copy source code and templates
COPY Cargo.lock ./
COPY src ./src
COPY templates ./templates
COPY static ./static
# Build the application
RUN cargo build --release
# Runtime Stage
FROM debian:bookworm-slim
# Install required dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the binary from builder
COPY --from=builder /usr/src/app/target/release/table-server /app/table-server
# Copy templates and static files
COPY --from=builder /usr/src/app/target/release/paramod /app/paramod
COPY --from=builder /usr/src/app/templates /app/templates
COPY --from=builder /usr/src/app/static /app/static
COPY paramod.yaml /app/paramod.yaml
# Create directory for config file
RUN mkdir -p /app/data
# Expose port
EXPOSE 8080
# Set environment to use the data directory
ENV CONFIG_PATH=/app/data/table_config.json
ENV CONFIG_PATH=/app/paramod.yaml
# Run the binary
CMD ["/app/table-server"]
CMD ["/app/paramod"]

View File

@ -5,7 +5,7 @@ Ein einfacher Rust-Webserver, der eine editierbare 3x3-Tabelle bereitstellt und
## Projektstruktur
```
table-server/
paramod/
├── src/
│ └── main.rs
├── templates/
@ -46,8 +46,8 @@ table-server/
```bash
# Projekt erstellen
cargo new table-server
cd table-server
cargo new paramod
cd paramod
# Dependencies installieren und starten
cargo run
@ -60,39 +60,17 @@ Der Server läuft dann auf `http://localhost:8080`
### Container bauen
```bash
docker build -t table-server .
podman build -t paramod .
```
### Container starten
```bash
docker run -p 8080:8080 -v $(pwd)/data:/app/data table-server
poddman run -p 8080:8080 -v $(pwd)/data:/app/data paramod
```
Mit Volume-Mount bleibt die Konfigurationsdatei auch nach Container-Neustarts erhalten.
### Docker Compose (optional)
Erstelle eine `docker-compose.yml`:
```yaml
version: '3.8'
services:
table-server:
build: .
ports:
- "8080:8080"
volumes:
- ./data:/app/data
restart: unless-stopped
```
Starten mit:
```bash
docker-compose up -d
```
## Verwendung
1. Öffne `http://localhost:8080` im Browser
@ -110,7 +88,7 @@ docker-compose up -d
- MQTT: Toggle-Schalter für MQTT-Aktivierung
- InfluxDB: Toggle-Schalter für InfluxDB-Aktivierung
4. **💾 Speichern**: Änderungen persistieren
5. Alle Daten werden zentral in `table_config.json` gespeichert
5. Alle Daten werden zentral in `paramod.yaml` gespeichert
## API Endpoints

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.3.0