- docker-compose.yml: Ollama, Gitea, Agent worker, Monitor services - Dockerfile.agent: Hermes agent worker image with health endpoint - .env.example: Environment variable template - README.md: Setup instructions and service documentation Services include health checks, persistent volumes, isolated network, and proper dependency ordering.
69 lines
1.9 KiB
Docker
69 lines
1.9 KiB
Docker
# Dockerfile.agent
|
|
# Dockerfile for the Hermes agent worker loop.
|
|
FROM python:3.12-slim
|
|
|
|
LABEL maintainer="Timmy Foundation"
|
|
LABEL description="Hermes agent worker for fleet-ops"
|
|
|
|
# Install system dependencies
|
|
RUN apt-get update && \
|
|
apt-get install -y --no-install-recommends \
|
|
curl \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy requirements first for layer caching
|
|
COPY requirements-agent.txt* ./
|
|
RUN if [ -f requirements-agent.txt ]; then \
|
|
pip install --no-cache-dir -r requirements-agent.txt; \
|
|
else \
|
|
pip install --no-cache-dir requests; \
|
|
fi
|
|
|
|
# Copy agent source if present
|
|
COPY agent/ ./agent/
|
|
|
|
# Health check endpoint (simple script if agent source not provided)
|
|
COPY --chmod=755 <<'EOF' /app/healthcheck.sh
|
|
#!/bin/sh
|
|
# Start a simple health endpoint
|
|
exec python3 -c "
|
|
import http.server, json, threading, time, os
|
|
|
|
class Handler(http.server.BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
if self.path == '/health':
|
|
self.send_response(200)
|
|
self.send_header('Content-Type', 'application/json')
|
|
self.end_headers()
|
|
self.wfile.write(json.dumps({'status': 'ok', 'agent': os.getenv('AGENT_NAME', 'hermes')}).encode())
|
|
else:
|
|
self.send_response(404)
|
|
self.end_headers()
|
|
def log_message(self, format, *args): pass
|
|
|
|
s = http.server.HTTPServer(('0.0.0.0', 8080), Handler)
|
|
t = threading.Thread(target=s.serve_forever, daemon=True)
|
|
t.start()
|
|
|
|
loop_interval = int(os.getenv('AGENT_LOOP_INTERVAL', '30'))
|
|
print(f'Agent loop starting (interval={loop_interval}s)')
|
|
while True:
|
|
try:
|
|
print(f'[{os.getenv(\"AGENT_NAME\", \"hermes\")}] tick')
|
|
time.sleep(loop_interval)
|
|
except KeyboardInterrupt:
|
|
break
|
|
s.shutdown()
|
|
"
|
|
EOF
|
|
|
|
EXPOSE 8080
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
|
|
CMD curl -sf http://localhost:8080/health || exit 1
|
|
|
|
CMD ["/app/healthcheck.sh"]
|