generated from nathanwoodburn/python-webserver-template
0ce79935d7f0b151ae59de27f3f32015188fc0cd
Home Lab Inventory
Flask inventory system for homelab environments with automatic data collection and a dashboard UI.
Features
- SQLite persistence for inventory, source health, and collection history
- Automatic scheduled polling with manual trigger API
- Connectors for:
- Proxmox (VM and LXC)
- Docker hosts
- Coolify instances
- Nginx config ingestion from Docker agents
- Dashboard with topology cards and filterable inventory table
Requirements
- Python 3.13+
- UV
Development
- Install dependencies
uv sync
- Start app
uv run python3 server.py
- Optional pre-commit hooks
uv run pre-commit install
Production
python3 main.py
Environment Variables
Core
APP_NAMEdefault:Home Lab InventoryBASE_DIRdefault: current directoryDATABASE_PATHdefault:${BASE_DIR}/inventory.dbSCHEDULER_ENABLEDdefault:truePOLL_INTERVAL_SECONDSdefault:300INITIAL_COLLECT_ON_STARTUPdefault:trueREQUEST_TIMEOUT_SECONDSdefault:10ADMIN_TOKENoptional, required inX-Admin-Tokenfor manual trigger when set
Proxmox
PROXMOX_ENABLEDdefault:truePROXMOX_ENDPOINTScomma-separated URLs- Token auth:
PROXMOX_TOKEN_IDPROXMOX_TOKEN_SECRET
- Or username/password auth:
PROXMOX_USERPROXMOX_PASSWORD
PROXMOX_VERIFY_TLSdefault:false
Docker
DOCKER_ENABLEDdefault:trueDOCKER_HOSTScomma-separated Docker API endpointsDOCKER_HOSTsingle Docker endpoint (used ifDOCKER_HOSTSis empty)DOCKER_BEARER_TOKENoptionalDOCKER_AGENT_ENDPOINTScomma-separated inventory agent URLsDOCKER_AGENT_TOKENbearer token used by inventory agents
Docker endpoint examples:
DOCKER_HOST=unix:///var/run/docker.sock
DOCKER_HOSTS=tcp://docker-1:2376,tcp://docker-2:2376,https://docker-3.example/api
DOCKER_AGENT_ENDPOINTS=https://docker-a-agent:9090,https://docker-b-agent:9090,https://docker-c-agent:9090
DOCKER_AGENT_TOKEN=change-me
Coolify
COOLIFY_ENABLEDdefault:trueCOOLIFY_ENDPOINTScomma-separated URLsCOOLIFY_API_TOKEN
Nginx (via Docker Agent)
- Nginx config data is collected from each Docker agent endpoint (
/api/v1/nginx-configs). - No separate NPM API credentials are required in the inventory app.
API Endpoints
GET /api/v1/summaryGET /api/v1/topologyGET /api/v1/assetsGET /api/v1/sourcesGET /api/v1/healthPOST /api/v1/collect/trigger
Docker Notes
- Persist DB with a volume mounted into
BASE_DIRor setDATABASE_PATH - If you need local Docker socket collection, expose Docker API via a secure endpoint or add your preferred socket proxy
Multi-Server Docker Agent Pattern
- For one local Docker host, use
DOCKER_HOST=unix:///var/run/docker.sock. - For multiple Docker servers, run a small inventory agent on each Docker server and poll those agent endpoints from this app.
- Agent responsibilities:
- Read local Docker socket (
/var/run/docker.sock) on that host. - Optionally read mounted Nginx configuration files.
- Expose read-only inventory JSON over HTTPS.
- Authenticate requests with a bearer token.
- Return container name, image, state, ports, and networks.
- Read local Docker socket (
- This avoids exposing Docker daemon APIs directly across your network.
Docker Agent Quick Start
Use the docker_agent/ folder to run one agent per Docker server.
- On each Docker server, copy the folder and start it:
cd docker_agent
docker compose up -d --build
- Set an agent token on each server (
AGENT_TOKEN) and expose port9090only to your inventory app network.
Nginx config support in docker agent:
- Mount your Nginx config directory into the agent container.
- Set
NGINX_CONFIG_DIRto the mounted path. - Query
GET /api/v1/nginx-configson the agent.
Example compose mount in docker_agent/docker-compose.yml:
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/nginx:/mnt/nginx:ro
environment:
NGINX_CONFIG_DIR: /mnt/nginx
- In the inventory app
.env, set:
DOCKER_ENABLED=true
DOCKER_AGENT_ENDPOINTS=http://docker1.local:9090,http://docker2.local:9090,http://docker3.local:9090
DOCKER_AGENT_TOKEN=change-me
- Trigger a collection in the UI and confirm
dockersource reportsokin the Sources panel.
Languages
Python
76.3%
HTML
15.9%
CSS
6.7%
Dockerfile
1.1%