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:
@@ -29,6 +29,17 @@ COPY --from=builder /app/nerd-monitor-agent .
|
||||
RUN addgroup -D appgroup && adduser -D appuser -G appgroup
|
||||
USER appuser
|
||||
|
||||
# Create entrypoint script to handle environment variables
|
||||
RUN echo '#!/bin/sh\n\
|
||||
SERVER=${SERVER:-localhost:8080}\n\
|
||||
INTERVAL=${INTERVAL:-15s}\n\
|
||||
AGENT_ID=${AGENT_ID:-}\n\
|
||||
if [ -z "$AGENT_ID" ]; then\n\
|
||||
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL"\n\
|
||||
else\n\
|
||||
exec ./nerd-monitor-agent --server "$SERVER" --interval "$INTERVAL" --id "$AGENT_ID"\n\
|
||||
fi\n\
|
||||
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
||||
|
||||
# Run the agent
|
||||
ENTRYPOINT ["./nerd-monitor-agent"]
|
||||
CMD ["--server", "localhost:8080"]
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
Reference in New Issue
Block a user