fix(content): harden Docker practice guide

This commit is contained in:
yeasy
2026-06-16 21:23:21 -07:00
parent f4e684afeb
commit 9fdffa9d91
67 changed files with 343 additions and 278 deletions
+2 -5
View File
@@ -557,6 +557,8 @@ client-output-buffer-limit pubsub 32mb 8mb 60
**三层微服务架构示例**
> 下面示例聚焦服务拓扑网络健康检查和资源限制为便于阅读密码仍通过环境变量串接生产环境应改用 Compose secrets外部密钥系统或云厂商密钥服务并避免把敏感值写入 `DATABASE_URL` / `REDIS_URL`
```yaml
services:
# 前端服务
@@ -564,7 +566,6 @@ services:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: frontend
ports:
- "3000:3000"
environment:
@@ -586,7 +587,6 @@ services:
build:
context: ./api
dockerfile: Dockerfile
container_name: api
ports:
- "8000:8000"
environment:
@@ -619,7 +619,6 @@ services:
# PostgreSQL 数据库
postgres:
image: postgres:16-alpine
container_name: postgres
environment:
POSTGRES_DB: myappdb
POSTGRES_USER: appuser
@@ -641,7 +640,6 @@ services:
# Redis 缓存
redis:
image: redis:8-alpine
container_name: redis
command: ["sh", "-c", "redis-server --appendonly yes --requirepass \"$$REDIS_PASSWORD\""]
environment:
REDIS_PASSWORD: ${REDIS_PASSWORD:?set REDIS_PASSWORD}
@@ -659,7 +657,6 @@ services:
# Nginx 反向代理
nginx:
image: nginx:alpine
container_name: nginx
ports:
- "80:80"
- "443:443"