dividing dokcer compose into two
This commit is contained in:
parent
214528ed76
commit
ed950811b6
@ -82,13 +82,6 @@ done
|
|||||||
echo "✅ Database is ready"
|
echo "✅ Database is ready"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Create backup before deployment
|
|
||||||
echo -e "${YELLOW}💾 Creating database backup...${NC}"
|
|
||||||
BACKUP_FILE="backup_$(date +%Y%m%d_%H%M%S).sql"
|
|
||||||
docker exec $DB_CONTAINER pg_dump -U $DB_USER -d $DB_NAME > $BACKUP_FILE
|
|
||||||
echo "✅ Backup created: $BACKUP_FILE"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Deploy the SQL file
|
# Deploy the SQL file
|
||||||
echo -e "${YELLOW}🔧 Deploying database changes...${NC}"
|
echo -e "${YELLOW}🔧 Deploying database changes...${NC}"
|
||||||
echo "Executing: $SQL_FILE"
|
echo "Executing: $SQL_FILE"
|
||||||
|
@ -1,33 +1,6 @@
|
|||||||
services: # ───────────────────────────────────────────────────────────────────────────
|
services:
|
||||||
# 1. PostgreSQL Database
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
db:
|
# 1. .NET API
|
||||||
image: postgres:14-alpine
|
|
||||||
container_name: opencand_db
|
|
||||||
restart: unless-stopped
|
|
||||||
hostname: db
|
|
||||||
environment:
|
|
||||||
POSTGRES_USER: root
|
|
||||||
POSTGRES_PASSWORD: root
|
|
||||||
POSTGRES_DB: opencand
|
|
||||||
volumes:
|
|
||||||
- ./db-data:/var/lib/postgresql/data
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "pg_isready -U root -d opencand"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
logging:
|
|
||||||
driver: "json-file"
|
|
||||||
options:
|
|
||||||
max-size: "10m"
|
|
||||||
max-file: "3"
|
|
||||||
labels: "service=database"
|
|
||||||
labels:
|
|
||||||
- "promtail.enable=true"
|
|
||||||
- "promtail.job=opencand-db"
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
|
||||||
# 2. .NET API
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
api:
|
api:
|
||||||
container_name: opencand_api
|
container_name: opencand_api
|
||||||
@ -55,7 +28,7 @@ services: # ──────────────────────
|
|||||||
- "promtail.job=opencand-api"
|
- "promtail.job=opencand-api"
|
||||||
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
# 3. React + Vite Front‐end
|
# 2. React + Vite Front‐end
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
frontend:
|
frontend:
|
||||||
container_name: opencand_frontend
|
container_name: opencand_frontend
|
||||||
@ -66,7 +39,7 @@ services: # ──────────────────────
|
|||||||
depends_on:
|
depends_on:
|
||||||
- api
|
- api
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
# 4. ETL (Optional: runs once at startup)
|
# 3. ETL (Optional: runs once at startup)
|
||||||
#
|
#
|
||||||
# If you want the ETL to run on every compose up, give it restart: "no" or
|
# If you want the ETL to run on every compose up, give it restart: "no" or
|
||||||
# some other policy. It will run, then exit.
|
# some other policy. It will run, then exit.
|
||||||
@ -98,93 +71,3 @@ services: # ──────────────────────
|
|||||||
labels:
|
labels:
|
||||||
- "promtail.enable=true"
|
- "promtail.enable=true"
|
||||||
- "promtail.job=opencand-etl"
|
- "promtail.job=opencand-etl"
|
||||||
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
|
||||||
# 5. Log Monitoring Stack
|
|
||||||
# ───────────────────────────────────────────────────────────────────────────
|
|
||||||
# Loki - Log aggregation system
|
|
||||||
loki:
|
|
||||||
image: grafana/loki:2.9.0
|
|
||||||
container_name: opencand_loki
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:6110:3100"
|
|
||||||
command: -config.file=/etc/loki/local-config.yaml
|
|
||||||
volumes:
|
|
||||||
- ./monitoring/loki-config.yaml:/etc/loki/local-config.yaml
|
|
||||||
- loki-data:/loki
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"]
|
|
||||||
interval: 10s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 5
|
|
||||||
|
|
||||||
# Promtail - Log collection agent
|
|
||||||
promtail:
|
|
||||||
image: grafana/promtail:2.9.0
|
|
||||||
container_name: opencand_promtail
|
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
|
||||||
- ./monitoring/promtail-config.yaml:/etc/promtail/config.yml
|
|
||||||
- /var/log:/var/log:ro
|
|
||||||
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
|
||||||
command: -config.file=/etc/promtail/config.yml
|
|
||||||
depends_on:
|
|
||||||
- loki
|
|
||||||
|
|
||||||
# Prometheus - Metrics collection
|
|
||||||
prometheus:
|
|
||||||
image: prom/prometheus:v2.45.0
|
|
||||||
container_name: opencand_prometheus
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:6090:9090"
|
|
||||||
command:
|
|
||||||
- "--config.file=/etc/prometheus/prometheus.yml"
|
|
||||||
- "--storage.tsdb.path=/prometheus"
|
|
||||||
- "--web.console.libraries=/etc/prometheus/console_libraries"
|
|
||||||
- "--web.console.templates=/etc/prometheus/consoles"
|
|
||||||
- "--web.enable-lifecycle"
|
|
||||||
volumes:
|
|
||||||
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
|
||||||
- prometheus-data:/prometheus
|
|
||||||
depends_on:
|
|
||||||
- node-exporter
|
|
||||||
# Node Exporter - System metrics
|
|
||||||
node-exporter:
|
|
||||||
image: prom/node-exporter:v1.6.0
|
|
||||||
container_name: opencand_node_exporter
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:6100:9100"
|
|
||||||
volumes:
|
|
||||||
- /proc:/host/proc:ro
|
|
||||||
- /sys:/host/sys:ro
|
|
||||||
- /:/rootfs:ro
|
|
||||||
command:
|
|
||||||
- "--path.procfs=/host/proc"
|
|
||||||
- "--path.rootfs=/rootfs"
|
|
||||||
- "--path.sysfs=/host/sys"
|
|
||||||
- "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
|
|
||||||
# Grafana - Visualization and dashboards
|
|
||||||
grafana:
|
|
||||||
image: grafana/grafana:10.0.0
|
|
||||||
container_name: opencand_grafana
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "6000:3000"
|
|
||||||
environment:
|
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=admin
|
|
||||||
- GF_USERS_ALLOW_SIGN_UP=false
|
|
||||||
volumes:
|
|
||||||
- grafana-data:/var/lib/grafana
|
|
||||||
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
|
||||||
depends_on:
|
|
||||||
- loki
|
|
||||||
- prometheus
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
loki-data:
|
|
||||||
prometheus-data:
|
|
||||||
grafana-data:
|
|
||||||
|
115
infra-docker-compose.yaml
Normal file
115
infra-docker-compose.yaml
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:14-alpine
|
||||||
|
container_name: opencand_db
|
||||||
|
restart: unless-stopped
|
||||||
|
hostname: db
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: root
|
||||||
|
POSTGRES_PASSWORD: root
|
||||||
|
POSTGRES_DB: opencand
|
||||||
|
volumes:
|
||||||
|
- ./db-data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U root -d opencand"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "3"
|
||||||
|
labels: "service=database"
|
||||||
|
labels:
|
||||||
|
- "promtail.enable=true"
|
||||||
|
- "promtail.job=opencand-db"
|
||||||
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
|
# 5. Log Monitoring Stack
|
||||||
|
# ───────────────────────────────────────────────────────────────────────────
|
||||||
|
# Loki - Log aggregation system
|
||||||
|
loki:
|
||||||
|
image: grafana/loki:2.9.0
|
||||||
|
container_name: opencand_loki
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:6110:3100"
|
||||||
|
command: -config.file=/etc/loki/local-config.yaml
|
||||||
|
volumes:
|
||||||
|
- ./monitoring/loki-config.yaml:/etc/loki/local-config.yaml
|
||||||
|
- loki-data:/loki
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3100/ready || exit 1"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
# Promtail - Log collection agent
|
||||||
|
promtail:
|
||||||
|
image: grafana/promtail:2.9.0
|
||||||
|
container_name: opencand_promtail
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./monitoring/promtail-config.yaml:/etc/promtail/config.yml
|
||||||
|
- /var/log:/var/log:ro
|
||||||
|
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
|
command: -config.file=/etc/promtail/config.yml
|
||||||
|
depends_on:
|
||||||
|
- loki
|
||||||
|
|
||||||
|
# Prometheus - Metrics collection
|
||||||
|
prometheus:
|
||||||
|
image: prom/prometheus:v2.45.0
|
||||||
|
container_name: opencand_prometheus
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:6090:9090"
|
||||||
|
command:
|
||||||
|
- "--config.file=/etc/prometheus/prometheus.yml"
|
||||||
|
- "--storage.tsdb.path=/prometheus"
|
||||||
|
- "--web.console.libraries=/etc/prometheus/console_libraries"
|
||||||
|
- "--web.console.templates=/etc/prometheus/consoles"
|
||||||
|
- "--web.enable-lifecycle"
|
||||||
|
volumes:
|
||||||
|
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||||
|
- prometheus-data:/prometheus
|
||||||
|
depends_on:
|
||||||
|
- node-exporter
|
||||||
|
# Node Exporter - System metrics
|
||||||
|
node-exporter:
|
||||||
|
image: prom/node-exporter:v1.6.0
|
||||||
|
container_name: opencand_node_exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:6100:9100"
|
||||||
|
volumes:
|
||||||
|
- /proc:/host/proc:ro
|
||||||
|
- /sys:/host/sys:ro
|
||||||
|
- /:/rootfs:ro
|
||||||
|
command:
|
||||||
|
- "--path.procfs=/host/proc"
|
||||||
|
- "--path.rootfs=/rootfs"
|
||||||
|
- "--path.sysfs=/host/sys"
|
||||||
|
- "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
|
||||||
|
# Grafana - Visualization and dashboards
|
||||||
|
grafana:
|
||||||
|
image: grafana/grafana:10.0.0
|
||||||
|
container_name: opencand_grafana
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "6000:3000"
|
||||||
|
environment:
|
||||||
|
- GF_SECURITY_ADMIN_PASSWORD=admin
|
||||||
|
- GF_USERS_ALLOW_SIGN_UP=false
|
||||||
|
volumes:
|
||||||
|
- grafana-data:/var/lib/grafana
|
||||||
|
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
||||||
|
depends_on:
|
||||||
|
- loki
|
||||||
|
- prometheus
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
loki-data:
|
||||||
|
prometheus-data:
|
||||||
|
grafana-data:
|
Loading…
x
Reference in New Issue
Block a user