feat: add Grafana and Prometheus service configurations with Docker support

This commit is contained in:
2026-07-12 07:20:16 +08:00
parent 9cfb064a51
commit 7b3f32d387
4 changed files with 81 additions and 2 deletions
+2
View File
@@ -241,6 +241,8 @@ deploy-prometheus: pull
}
deploy-nodepad: pull
{ \
echo "Building the nodepad image..." ;\
docker build -t nodepad:latest -f ./swarm/inline.Dockerfile ./swarm ;\
echo "Deploying the nodepad stack..." ;\
set -a ;\
. ./swarm/.env ;\
+38
View File
@@ -0,0 +1,38 @@
volumes:
grafana_data: {}
networks:
traefik-public:
external: true
services:
grafana:
image: grafana/grafana:latest
environment:
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=false
- GF_INSTALL_PLUGINS=${GRAFANA_PLUGINS:-}
- GF_SERVER_ROOT_URL=https://grafana.${DOMAIN}
volumes:
- grafana_data:/var/lib/grafana
- /var/data/grafana/grafana.ini:/etc/grafana/grafana.ini:ro
- /var/data/grafana/provisioning:/etc/grafana/provisioning:ro
- /var/data/grafana/dashboards:/var/lib/grafana/dashboards:ro
networks:
- traefik-public
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=true
- traefik.swarm.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.grafana-https.rule=Host(`grafana.${DOMAIN?Variable not set}`)
- traefik.http.routers.grafana-https.entrypoints=https
- traefik.http.routers.grafana-https.tls=true
- traefik.http.routers.grafana-https.tls.certresolver=le
- traefik.http.services.grafana.loadbalancer.server.port=3000
+1 -2
View File
@@ -1,6 +1,6 @@
services:
nodepad:
container_name: nodepad
image: nodepad:latest
build:
context: .
dockerfile: inline.Dockerfile
@@ -11,7 +11,6 @@ services:
# Add your AI model API keys below if needed by the app:
# - OPENAI_API_KEY=your_key_here
# - ANTHROPIC_API_KEY=your_key_here
restart: unless-stopped
networks:
- traefik-public
deploy:
+40
View File
@@ -0,0 +1,40 @@
volumes:
prometheus_data: {}
networks:
traefik-public:
external: true
services:
prometheus:
image: prom/prometheus:latest
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION:-30d}'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
volumes:
- prometheus_data:/prometheus
- /var/data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- /var/data/prometheus/rules:/etc/prometheus/rules:ro
networks:
- traefik-public
deploy:
mode: replicated
replicas: 1
placement:
constraints:
- node.role == manager
labels:
- traefik.enable=true
- traefik.swarm.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.prometheus-https.rule=Host(`prometheus.${DOMAIN?Variable not set}`)
- traefik.http.routers.prometheus-https.entrypoints=https
- traefik.http.routers.prometheus-https.tls=true
- traefik.http.routers.prometheus-https.tls.certresolver=le
- traefik.http.services.prometheus.loadbalancer.server.port=9090
- traefik.http.middlewares.prometheus-auth.basicauth.users=${ADMIN_USER?Variable not set}:${HASHED_PASSWORD?Variable not set}
- traefik.http.routers.prometheus-https.middlewares=prometheus-auth