Major improvements: multi-stage Docker, security hardening, host metrics, tests

- Multi-stage Docker build: Dockerfile compiles frontend (Node.js) and
  backend (Gradle) inside Docker; no local Java/Node.js required
- Security hardening: replaced full host root mount with specific
  directory mounts (/proc, /sys, /etc, /var, /home, /opt, /tmp, /srv, /usr)
- Host metrics consistency: LinuxMemoryService and CpuDetailsService now
  read from /host/proc instead of container OSHI
- Concurrency: replaced synchronized with AtomicReference in 3 services
- Global error handling: added @RestControllerAdvice for JSON error responses
- Unit tests: added 32 tests for /proc parsers, CPU usage, process uptime
- Docker security: non-root user, read-only FS, no-new-privileges, healthcheck
- Debug logging: added log.debug() in silent catch blocks
- Documentation: updated README, INSTALLATION, DEVELOPMENT, CONFIGURATION,
  ARCHITECTURE, CHANGELOG

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
2026-10-28 23:18:01 +01:00
co-authored by Junie
parent 539175654c
commit 597d8f380a
23 changed files with 1122 additions and 137 deletions
+34 -16
View File
@@ -63,16 +63,29 @@ The Angular frontend is built for production and packaged into the Spring Boot a
## Simple Scenario of using
```bash
```yaml
services:
htop-web:
image: gitea.jambotron.com/liosha84/htop-web:latest
container_name: htop-web
restart: unless-stopped
pid: host
read_only: true
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:noexec,nosuid,size=64m
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/host/root:ro
- /etc/hostname:/host/etc/hostname:ro
- /etc/os-release:/host/etc/os-release:ro
- /var:/host/var:ro
- /home:/host/home:ro
- /opt:/host/opt:ro
- /tmp:/host/tmp:ro
- /srv:/host/srv:ro
- /usr:/host/usr:ro
labels:
caddy: htop-web.jambotron.com
caddy.reverse_proxy: "{{upstreams 8080}}"
@@ -84,7 +97,7 @@ networks:
external: true
```
```bash
```bash
docker compose up -d
```
@@ -93,13 +106,28 @@ docker compose up -d
### Requirements
- Java 21 and a compatible Node.js/npm installation for local builds.
- Docker Engine or Docker Desktop.
- Docker Compose.
### 1. Build the application
No local Java or Node.js is required — the Dockerfile uses multi-stage build to compile everything inside Docker.
Run from the repository root.
### 1. Build and start the container
From the repository root, run a single command:
```bash
docker compose up -d --build
```
The `--build` flag triggers the multi-stage Docker build that compiles both the Angular frontend and the Spring Boot backend inside Docker.
The default Compose configuration maps host port `8088` to container port `8080`.
Open [http://localhost:8088](http://localhost:8088).
### Alternative: Local Gradle build (requires Java 21 and Node.js)
If you need to build locally (for example, to run tests):
**Linux:**
@@ -119,16 +147,6 @@ cd ..
The configured Gradle build builds the frontend and packages its production assets with the backend.
### 2. Build and start the container
```bash
docker compose up -d --build
```
The default Compose configuration maps host port `8088` to container port `8080`.
Open [http://localhost:8088](http://localhost:8088).
### 3. Inspect logs
```bash