Geräte-Agent als Container verpacken
This commit is contained in:
6
agents/fedeo-device-agent/.dockerignore
Normal file
6
agents/fedeo-device-agent/.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
dist
|
||||
.venv-opencv
|
||||
.env
|
||||
*.log
|
||||
*.tmp
|
||||
45
agents/fedeo-device-agent/Dockerfile
Normal file
45
agents/fedeo-device-agent/Dockerfile
Normal file
@@ -0,0 +1,45 @@
|
||||
FROM node:20-bookworm-slim AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package.json tsconfig.json ./
|
||||
RUN npm install
|
||||
|
||||
COPY src ./src
|
||||
RUN npm run build
|
||||
|
||||
FROM node:20-bookworm-slim AS runtime
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV FEDEO_WORK_DIR=/work
|
||||
ENV FEDEO_SCAN_POSTPROCESS=true
|
||||
ENV FEDEO_SCAN_POSTPROCESS_PROFILE=receipt
|
||||
ENV FEDEO_SCAN_POSTPROCESS_PYTHON=/opt/fedeo-device-agent/.venv-opencv/bin/python
|
||||
ENV FEDEO_SCAN_POSTPROCESS_STRICT=false
|
||||
|
||||
WORKDIR /opt/fedeo-device-agent
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
cups-client \
|
||||
libgomp1 \
|
||||
python3 \
|
||||
python3-pip \
|
||||
python3-venv \
|
||||
sane-utils \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements-opencv.txt ./
|
||||
RUN python3 -m venv .venv-opencv \
|
||||
&& .venv-opencv/bin/python -m pip install --no-cache-dir --upgrade pip \
|
||||
&& .venv-opencv/bin/python -m pip install --no-cache-dir -r requirements-opencv.txt \
|
||||
&& .venv-opencv/bin/python -c "import cv2, PIL, numpy"
|
||||
|
||||
COPY --from=build /app/dist ./dist
|
||||
COPY scripts ./scripts
|
||||
COPY package.json ./
|
||||
|
||||
RUN mkdir -p /work
|
||||
|
||||
CMD ["node", "dist/main.js"]
|
||||
@@ -78,6 +78,30 @@ Profile:
|
||||
- `document`: allgemeine Dokumente mit Farberhalt und moderater Verbesserung.
|
||||
- `raw`: Zuschnitt/Entzerrung ohne starke Kontrastkorrektur.
|
||||
|
||||
## Container-Betrieb
|
||||
|
||||
Auf Linux und Raspberry Pi OS kann der Agent komplett im Container laufen. Dadurch bleiben Node.js, Python, OpenCV und SANE im Image. Auf dem Host werden dann nur Docker und Zugriff auf den USB-Scanner benötigt.
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
nano .env
|
||||
docker compose -f docker-compose.example.yml up --build
|
||||
```
|
||||
|
||||
Wenn FEDEO lokal auf dem Docker-Host läuft, verwende im Container nicht `localhost`, sondern:
|
||||
|
||||
```env
|
||||
FEDEO_URL=http://host.docker.internal:3100
|
||||
```
|
||||
|
||||
Scanner im Container prüfen:
|
||||
|
||||
```bash
|
||||
docker compose -f docker-compose.example.yml run --rm fedeo-device-agent scanimage -L
|
||||
```
|
||||
|
||||
Wenn der Scanner nicht sichtbar ist, hilft je nach Gerät/Host manchmal `privileged: true` im Compose-Beispiel. Auf macOS ist Docker dafür nur eingeschränkt geeignet, weil Docker Desktop USB-Scanner normalerweise nicht direkt an Linux-Container durchreichen kann. Für macOS bleibt deshalb der native Agent oder später eine signierte App der bessere Weg.
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
|
||||
28
agents/fedeo-device-agent/docker-compose.example.yml
Normal file
28
agents/fedeo-device-agent/docker-compose.example.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
services:
|
||||
fedeo-device-agent:
|
||||
build:
|
||||
context: .
|
||||
image: fedeo-device-agent:local
|
||||
container_name: fedeo-device-agent
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
FEDEO_WORK_DIR: /work
|
||||
FEDEO_SCAN_POSTPROCESS: "true"
|
||||
FEDEO_SCAN_POSTPROCESS_PROFILE: receipt
|
||||
FEDEO_SCAN_POSTPROCESS_PYTHON: /opt/fedeo-device-agent/.venv-opencv/bin/python
|
||||
FEDEO_SCAN_POSTPROCESS_STRICT: "false"
|
||||
volumes:
|
||||
- fedeo-device-agent-work:/work
|
||||
# Optional fuer CUPS-Druck ueber den Host:
|
||||
# - /var/run/cups/cups.sock:/var/run/cups/cups.sock
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
devices:
|
||||
- /dev/bus/usb:/dev/bus/usb
|
||||
# Falls SANE den Scanner trotz devices-Mapping nicht sieht, testweise aktivieren:
|
||||
# privileged: true
|
||||
|
||||
volumes:
|
||||
fedeo-device-agent-work:
|
||||
Reference in New Issue
Block a user