Skip to content

Commit

Permalink
feat: add more images
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw committed Dec 13, 2024
1 parent 34d9730 commit 3ea416e
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,31 @@ jobs:
dockerfile: ./compose/production/python-3-12-slim-bookworm/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/python-3-12-slim-bookworm/
- project: prometheus
context: .
dockerfile: ./compose/production/prometheus/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/prometheus/
- project: node_exporter
context: .
dockerfile: ./compose/production/node_exporter/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/node_exporter/
- project: grafana
context: .
dockerfile: ./compose/production/grafana/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/grafana/
- project: loki
context: .
dockerfile: ./compose/production/loki/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/loki/
- project: promtail
context: .
dockerfile: ./compose/production/promtail/Dockerfile
architectures: linux/amd64,linux/arm64
path: ./compose/production/promtail/

steps:
- name: Checkout code
Expand Down
12 changes: 12 additions & 0 deletions compose/production/grafana/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM grafana/grafana:latest

# 设置时区
ENV TZ=Asia/Shanghai

# 设置默认管理员账号密码
ENV GF_SECURITY_ADMIN_USER=admin \

Check warning on line 7 in compose/production/grafana/Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-push (grafana, ., ./compose/production/grafana/Dockerfile, linux/amd64,linux/arm64, ./c...

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "GF_SECURITY_ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

Check warning on line 7 in compose/production/grafana/Dockerfile

View workflow job for this annotation

GitHub Actions / build-and-push (grafana, ., ./compose/production/grafana/Dockerfile, linux/amd64,linux/arm64, ./c...

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "GF_SECURITY_ADMIN_PASSWORD") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/
GF_SECURITY_ADMIN_PASSWORD=123456

# 健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3000/api/health || exit 1
8 changes: 8 additions & 0 deletions compose/production/loki/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM grafana/loki:2.9.0

COPY ./compose/production/loki/loki-config.yml /etc/loki/

USER root

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3100/ready || exit 1
52 changes: 52 additions & 0 deletions compose/production/loki/loki-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
auth_enabled: false

server:
http_listen_port: 3100

ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s

schema_config:
configs:
- from: 2020-05-15
store: boltdb-shipper
object_store: filesystem
schema: v11
index:
prefix: index_
period: 24h

storage_config:
boltdb_shipper:
active_index_directory: /tmp/loki/boltdb-shipper-active
cache_location: /tmp/loki/boltdb-shipper-cache
cache_ttl: 24h
shared_store: filesystem
filesystem:
directory: /tmp/loki/chunks

limits_config:
retention_period: 744h
max_query_length: 744h

ruler:
storage:
type: local
local:
directory: /tmp/loki/rules
rule_path: /tmp/loki/rules-temp
alertmanager_url: http://localhost:9093
ring:
kvstore:
store: inmemory

compactor:
working_directory: /tmp/loki/boltdb-shipper-compactor
10 changes: 10 additions & 0 deletions compose/production/node_exporter/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM prom/node-exporter:latest

# 设置默认参数
ENV PATH_SYSFS=/host/sys \
PATH_PROCFS=/host/proc \
PATH_ROOTFS=/rootfs

# 健康检查
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:9100/metrics || exit 1
3 changes: 3 additions & 0 deletions compose/production/prometheus/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM prom/prometheus:latest

COPY ./compose/production/prometheus/prometheus.yml /etc/prometheus/
15 changes: 15 additions & 0 deletions compose/production/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
global:
scrape_interval: 15s # 全局抓取间隔

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']

- job_name: 'django'
static_configs:
- targets: ['django:8000']

- job_name: 'node_exporter'
static_configs:
- targets: ['node_exporter:9100']
6 changes: 6 additions & 0 deletions compose/production/promtail/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM grafana/promtail:latest

COPY ./compose/production/promtail/promtail-config.yml /etc/promtail/

HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:9080/ready || exit 1
18 changes: 18 additions & 0 deletions compose/production/promtail/promtail-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
server:
http_listen_port: 9080
grpc_listen_port: 0

positions:
filename: /tmp/positions.yaml

clients:
- url: http://loki:3100/loki/api/v1/push

scrape_configs:
- job_name: system
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /app/logs/*.log

0 comments on commit 3ea416e

Please sign in to comment.