Update nexus: fix conflicts and sync local changes

This commit is contained in:
Shen Wei
2026-04-26 12:06:50 +08:00
parent 191797c01b
commit f09834b5a5
2443 changed files with 254323 additions and 255154 deletions

View File

@@ -1,113 +1,113 @@
---
title: Docker堆栈
type: concept
tags: [docker, compose, orchestration]
date: 2025-12-29
---
# Docker堆栈
## Definition
Docker 堆栈Docker Stack是指通过 Docker Compose 编排的多容器应用,由多个相互依赖的服务组成,共同提供完整功能。在 [[Zipline]] 图床方案中MinIO + PostgreSQL + Zipline 构成一个完整的堆栈。
## Zipline Stack Architecture
```yaml
services:
minio: # S3 兼容存储
image: minio/minio:latest
depends_on: []
postgres: # 元数据库
image: postgres:16
depends_on: []
zipline: # 图床应用
image: ghcr.io/diced/zipline:latest
depends_on:
minio:
condition: service_healthy
postgres:
condition: service_healthy
```
## Service Dependency Patterns
### Pattern 1: Simple depends_on
```yaml
service_a:
depends_on:
- service_b
```
仅确保启动顺序,不等待就绪。
### Pattern 2: Health Check + Condition本方案推荐
```yaml
service_b:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/health"]
interval: 30s
retries: 3
service_a:
depends_on:
service_b:
condition: service_healthy
```
确保依赖服务就绪后才启动,避免竞态条件。
### Pattern 3: wait-for Script
```bash
#!/bin/bash
wait-for-it.sh service:port -- echo "Service is ready"
```
## Key Compose Features Used
| 功能 | 配置 | 说明 |
|------|------|------|
| 健康检查 | `healthcheck` | 自动检测服务状态 |
| 条件依赖 | `condition: service_healthy` | 等待健康检查通过 |
| 资源限制 | `deploy.resources.limits` | 防止单服务耗尽资源 |
| 重启策略 | `restart: unless-stopped` | 异常自动重启 |
| 端口映射 | `ports` | 暴露服务端口 |
| 卷挂载 | `volumes` | 数据持久化 |
## Resource Limits in This Stack
| 服务 | 内存限制 | 说明 |
|------|----------|------|
| MinIO | 1G | S3 存储,缓存友好 |
| PostgreSQL | 512M | 元数据,索引优先 |
| Zipline | 512M | Node.js适中即可 |
## Volume Persistence
| 卷路径 | 内容 | 备份策略 |
|--------|------|----------|
| `/volume1/docker/zipline-stack/minio/minio_data` | 图片文件 | Synology Hyper Backup |
| `/volume1/docker/zipline-stack/zipline/pg_data` | 数据库文件 | **不要直接备份**(见下) |
### Important: Database Volume Warning
> **警告**:不要直接备份 PostgreSQL 数据目录(`/var/lib/postgresql/data`
>
> 热备份运行中的数据库目录会导致数据损坏。应使用 `pg_dump` 逻辑备份。
正确方式:
```bash
# 使用 pg_dump 逻辑备份(热备份,安全)
docker exec zipline_postgres pg_dump -U zipline -d zipline | gzip > backup.sql.gz
```
## Connections
- [[MinIO]] ← part of ← [[Docker堆栈]]
- [[PostgreSQL]] ← part of ← [[Docker堆栈]]
- [[Zipline]] ← part of ← [[Docker堆栈]]
- [[群晖 NAS]] ← hosts ← [[Docker堆栈]]
## Related Concepts
- [[Docker Compose]]
- [[容器资源限制]]
- [[容器重启策略]]
- [[逻辑备份]]
---
title: Docker堆栈
type: concept
tags: [docker, compose, orchestration]
date: 2025-12-29
---
# Docker堆栈
## Definition
Docker 堆栈Docker Stack是指通过 Docker Compose 编排的多容器应用,由多个相互依赖的服务组成,共同提供完整功能。在 [[Zipline]] 图床方案中MinIO + PostgreSQL + Zipline 构成一个完整的堆栈。
## Zipline Stack Architecture
```yaml
services:
minio: # S3 兼容存储
image: minio/minio:latest
depends_on: []
postgres: # 元数据库
image: postgres:16
depends_on: []
zipline: # 图床应用
image: ghcr.io/diced/zipline:latest
depends_on:
minio:
condition: service_healthy
postgres:
condition: service_healthy
```
## Service Dependency Patterns
### Pattern 1: Simple depends_on
```yaml
service_a:
depends_on:
- service_b
```
仅确保启动顺序,不等待就绪。
### Pattern 2: Health Check + Condition本方案推荐
```yaml
service_b:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/health"]
interval: 30s
retries: 3
service_a:
depends_on:
service_b:
condition: service_healthy
```
确保依赖服务就绪后才启动,避免竞态条件。
### Pattern 3: wait-for Script
```bash
#!/bin/bash
wait-for-it.sh service:port -- echo "Service is ready"
```
## Key Compose Features Used
| 功能 | 配置 | 说明 |
|------|------|------|
| 健康检查 | `healthcheck` | 自动检测服务状态 |
| 条件依赖 | `condition: service_healthy` | 等待健康检查通过 |
| 资源限制 | `deploy.resources.limits` | 防止单服务耗尽资源 |
| 重启策略 | `restart: unless-stopped` | 异常自动重启 |
| 端口映射 | `ports` | 暴露服务端口 |
| 卷挂载 | `volumes` | 数据持久化 |
## Resource Limits in This Stack
| 服务 | 内存限制 | 说明 |
|------|----------|------|
| MinIO | 1G | S3 存储,缓存友好 |
| PostgreSQL | 512M | 元数据,索引优先 |
| Zipline | 512M | Node.js适中即可 |
## Volume Persistence
| 卷路径 | 内容 | 备份策略 |
|--------|------|----------|
| `/volume1/docker/zipline-stack/minio/minio_data` | 图片文件 | Synology Hyper Backup |
| `/volume1/docker/zipline-stack/zipline/pg_data` | 数据库文件 | **不要直接备份**(见下) |
### Important: Database Volume Warning
> **警告**:不要直接备份 PostgreSQL 数据目录(`/var/lib/postgresql/data`
>
> 热备份运行中的数据库目录会导致数据损坏。应使用 `pg_dump` 逻辑备份。
正确方式:
```bash
# 使用 pg_dump 逻辑备份(热备份,安全)
docker exec zipline_postgres pg_dump -U zipline -d zipline | gzip > backup.sql.gz
```
## Connections
- [[MinIO]] ← part of ← [[Docker堆栈]]
- [[PostgreSQL]] ← part of ← [[Docker堆栈]]
- [[Zipline]] ← part of ← [[Docker堆栈]]
- [[群晖 NAS]] ← hosts ← [[Docker堆栈]]
## Related Concepts
- [[Docker Compose]]
- [[容器资源限制]]
- [[容器重启策略]]
- [[逻辑备份]]