mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 08:27:25 +00:00
fix(content): harden Compose credential examples
This commit is contained in:
@@ -96,14 +96,14 @@ $ touch Gemfile.lock
|
||||
|
||||
### 11.7.5 步骤 3:创建 compose.yaml
|
||||
|
||||
配置如下:
|
||||
配置如下。下面为了本地练习使用环境变量占位;不要把真实数据库密码写进 `compose.yaml`、`.env` 或 Git,生产环境应使用 Compose secrets、Rails credentials 或平台密钥管理。
|
||||
|
||||
```yaml
|
||||
services:
|
||||
db:
|
||||
image: postgres:16
|
||||
environment:
|
||||
POSTGRES_PASSWORD: password
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
@@ -123,7 +123,7 @@ services:
|
||||
db:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DATABASE_URL: postgres://postgres:password@db:5432/myapp_development
|
||||
DATABASE_URL: postgres://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD}@db:5432/myapp_development
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
|
||||
Reference in New Issue
Block a user