Skip to content

Containerize services and add reverse proxy#12

Open
rensortino wants to merge 13 commits into
djosix:masterfrom
rensortino:feat/docker
Open

Containerize services and add reverse proxy#12
rensortino wants to merge 13 commits into
djosix:masterfrom
rensortino:feat/docker

Conversation

@rensortino
Copy link
Copy Markdown

This pull request introduces Docker-based deployment for ServStat, for better portability and ease of configuration. It containerizes the backend and frontend, adds a docker-compose.yml for orchestrating services, and updates the documentation to recommend Docker deployment. The backend container uses a CUDA-based image to allow for GPU monitoring and an Nginx reverse proxy is configured to route requests to the appropriate services.

Dockerization and Deployment

  • Added docker-compose.yml to define and orchestrate backend, frontend, and Nginx services, including GPU allocation for backend and custom networking.
  • Added Makefile with convenient targets for building, starting, stopping, and managing Docker services.
  • Added backend/Dockerfile and frontend/Dockerfile for containerizing both backend and frontend applications.
  • Added nginx.conf to configure Nginx as a reverse proxy, routing /stat/ API requests to backend and all other requests to frontend, with error handling and fallback messaging.

Documentation Updates

  • Updated README.md to recommend Docker deployment, provide step-by-step Docker instructions, and clarify backend/frontend roles.

Frontend Dependencies update

  • Updated frontend dependencies to latest Vite version, and added Vite Vue plugin configuration for compatibility with Vite 6.

…tainer hostname

cpu_freq() returns None on some kernels (notably inside containers) and
crashed _asdict(); disk_info() reported nothing on bare-metal because
the function was hard-wired to /host_root; os.uname()[1] returned the
container hostname ("backend") instead of the host's; a bare except
swallowed everything in gpu_info(). Wrap the freq lookup, detect
/host_root vs bare-metal partitions, prefer HOST_HOSTNAME from the
environment, and narrow the except to Exception.
The frontend container is now both the static SPA server and the reverse
proxy: nginx.conf moves into frontend/, the Dockerfile bakes it into the
nginx:alpine stage, and the separate nginx service is dropped. Port 80
is published from the frontend service and routes /stat/ to the backend
over the internal compose network — the backend container no longer
exposes a host port. HOST_HOSTNAME is passed through so /stat reports
the real host name.

The frontend Dockerfile also moves from the EOL node:14.16.0 to
node:20-alpine, which is required by Vite 6. config.json defaults to
the same-origin proxied path, and the Makefile rebuild-frontend target
is rewritten around docker compose (the previous version was an
unfinished shell pipeline that did not work).
When config.json points at a same-origin path like "/stat/", the
original regex required https?:// and threw, falling back to "[uknown
address]". Use new URL(link, window.location.href) so relative links
resolve to the proxy host and hostnames containing dashes also parse.
Adds a bar between Swap and the per-disk table that sums total/used
across all reported partitions (skipping /boot, matching the existing
table filter). On the docker deployment this reflects the host root
plus any additional bind-mounted host paths the backend exposes.
Many of our hosts keep datasets and model checkpoints on a separate
/data filesystem that doesn't show up under /host_root. Add a bind
mount and probe /host_data alongside /host_root in disk_info(), so the
aggregated disk bar reflects the real picture. When /data is absent
on the host, docker creates an empty dir there and the bind resolves
to the root filesystem — the backend compares st_dev against root and
skips it to avoid double-counting.
Captures the two-tier architecture (each monitored host runs its own
backend; the frontend polls the configured /stat URLs at runtime),
the contract between /stat and App.vue, the compose layout, and the
nginx pattern for adding LAN backends through a single port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant