Add docker-compose support with environment variable configuration

- Create docker-compose.yml with server and agent services
- Add environment variable support to Dockerfiles via entrypoint scripts
- Configure server with ADDR, PORT, USERNAME, PASSWORD vars
- Configure agent with SERVER, INTERVAL, AGENT_ID vars
- Add health check to server service for container orchestration
- Add service dependencies to ensure server starts before agent
- Create .dockerignore to optimize Docker builds
- Update QUICKSTART.md with Docker Compose instructions
- Support running server only, agent only, or full stack
- Support multiple agents with custom identifiers
This commit is contained in:
Ducky SSH User
2025-12-20 05:57:09 +00:00
parent 9184de0a1d
commit 98ecc61624
5 changed files with 216 additions and 5 deletions

107
docker-compose.yml Normal file
View File

@@ -0,0 +1,107 @@
version: '3.8'
# ============================================================================
# Nerd Monitor Docker Compose Configuration
# ============================================================================
#
# This file provides multiple ways to run Nerd Monitor:
#
# 1. Full Stack (Server + Agent):
# docker-compose up
#
# 2. Server Only:
# docker-compose up server
#
# 3. Agent Only (requires external server):
# docker-compose up agent
# (Set SERVER env var: SERVER=your-server:8080 docker-compose up agent)
#
# 4. Multiple Agents:
# docker-compose up -d server
# docker-compose run --name agent1 -e AGENT_ID=machine1 agent
# docker-compose run --name agent2 -e AGENT_ID=machine2 agent
#
# ============================================================================
services:
# =========================================================================
# Nerd Monitor Server
# =========================================================================
# Web UI and API endpoint for collecting agent statistics
#
# Environment Variables:
# ADDR: Server bind address (default: 0.0.0.0)
# PORT: Server port (default: 8080)
# USERNAME: Admin username (default: admin)
# PASSWORD: Admin password (default: admin) - CHANGE IN PRODUCTION
#
server:
build:
context: .
dockerfile: Dockerfile.server
container_name: nerd-monitor-server
image: nerd-monitor-server:latest
ports:
- "8080:8080"
environment:
# Server configuration
ADDR: "0.0.0.0"
PORT: "8080"
# IMPORTANT: Change these credentials in production!
USERNAME: "admin"
PASSWORD: "admin"
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/login"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
restart: unless-stopped
networks:
- nerd-monitor
# Resource limits (optional, uncomment to enable)
# deploy:
# resources:
# limits:
# cpus: '0.5'
# memory: 512M
# =========================================================================
# Nerd Monitor Agent
# =========================================================================
# Lightweight monitoring agent that reports system stats to the server
#
# Environment Variables:
# SERVER: Server address (default: server:8080 when using docker-compose)
# INTERVAL: Reporting interval (default: 15s)
# AGENT_ID: Optional agent identifier (auto-generated from hostname if empty)
#
# Note: This agent depends on the server being healthy before starting
#
agent:
build:
context: .
dockerfile: Dockerfile.agent
image: nerd-monitor-agent:latest
environment:
# Agent configuration
SERVER: "server:8080" # Connect to the server service
INTERVAL: "15s" # Report stats every 15 seconds
# AGENT_ID: "my-machine" # Optional: set a custom agent ID
depends_on:
server:
condition: service_healthy # Wait for server to be healthy
restart: unless-stopped
networks:
- nerd-monitor
# Resource limits (optional, uncomment to enable)
# deploy:
# resources:
# limits:
# cpus: '0.25'
# memory: 128M
networks:
# Shared network for server and agent communication
nerd-monitor:
driver: bridge