6 Commits
Author SHA1 Message Date
yeasy 659473e6d8 fix(demo): 三个配套示例目录与其章节漂移,其中两处带真实后果
章节里写着「完整的文件如下」,仓库里配套的实际文件却已经和正文对不上。
这类漂移比正文里的笔误更隐蔽——读者按目录跑起来的是另一份东西。

- `11_compose/demo/django/Dockerfile` 用的是 `ENV PYTHONUNBUFFERED 1` 这种
  空格旧写法,而 7.6 节写着绝对规则:「已被官方弃用……`docker buildx build
  --check` 会直接把它标出来。**一律用等号**」。这是全仓唯一一处违反(已扫过
  全部 md 与 11 个 Dockerfile)。同文件还有三处与 11.6 节不符:`FROM python:3`
  (章节是 3.12-slim)、`pip install` 缺 `--no-cache-dir`(章节专门列表讲了
  它的作用)、requirements 用 psycopg2 而章节表格写着「推荐使用 psycopg 3」。
  按 11.6 同步,现与章节代码块逐字节一致。
- `07_dockerfile/multistage_example/laravel/Dockerfile` 与 7.18 节差三处,
  两处有实质后果:`chmod -R 777 storage`(章节是 `chown www-data` + `775`)
  —— 而 18.5 节正拿 `777` 当"全员读写权限"的风险范例;以及 `COPY composer.json`
  漏掉了 `composer.lock`,正好破坏该章论证的可复现性。第三处 nginx 标签
  1.30 与全书 20 处 1.28 不一致(且章节自己的注释就推荐 1.28-alpine)。
  同步后与章节仅差章节独有的那行说明性注释。
- `11_compose/demo/wordpress/docker-compose.yml` 的 wordpress 服务**完全没有
  `volumes:`**,而 11.8 节专门加粗警告过「`volumes` 配置很重要!没有它,每次
  容器重启数据都会丢失」并声明了 `wp_data`。该 demo 恰好演示了章节警告的那个
  故障。另外还缺 `wp_net`、两个 container_name、`WORDPRESS_DB_NAME` 与
  `uploads.ini` 挂载。按章节同步,并补上章节 11.8.3 已给出内容的 `uploads.ini`
  (否则挂载会指向不存在的文件)。同步后 YAML 实测可解析,volumes 为
  db_data + wp_data。

`secrets/` 目录未补:它被 .gitignore 有意排除,demo 的 README 就是教读者
自己创建的,属于设计而非缺失。
2026-09-04 14:56:23 -07:00
yeasy 9fdffa9d91 fix(content): harden Docker practice guide 2026-06-16 21:23:21 -07:00
yeasy 0cfd55af7b fix(content): repair Django tutorial crash and complete the hardening sweep
Follow-ups to the 9 secret-hardening commits (each verified against
docs.docker.com / vendor docs; one outright new bug found and fixed):

- 11.6: eb5e4397 changed settings.py to a hard os.environ lookup but the
  web service never receives POSTGRES_PASSWORD (only db does; DATABASE_URL
  is set but never read) -> step-6 'docker compose up' crashed with
  KeyError. Pass the var to web; harden the leftover literal password in
  the 配置详解 snippet that contradicted the new guidance two lines down;
  blank line after the inserted sentence (bold heading merged into the
  paragraph); dev/prod table no longer claims dev uses 明文 passwords
- 11.8: FAQ still told readers to check passwords in .env after the same
  file banned passwords in .env -> point at secrets/db_password.txt;
  backup sidecar env vars updated to tiredofit/db-backup 4.x interface
  (DB01_* + DB01_PASS_FILE + DB01_BACKUP_INTERVAL - the unprefixed DB_*
  names are ignored by current :latest; verified against upstream README)
- demo/wordpress: compose now references secrets files that ship nowhere
  -> add README with the creation commands from 11.8; demo/django: align
  with the hardened 11.6 (env-injected password, passed to web too)
- 04_image multistage demos: go build without go.mod fails on module-mode
  Go (reproduced by reviewer on go1.26) -> add 'go mod init helloworld'
  matching the 7.17 doc pattern in all three Dockerfiles
- 21.7: init script reworked init-db.sql -> init-db.sh per the official
  image's env-reading .sh hook - removes the baked 'secure_password' AND
  the CREATE DATABASE myappdb collision with POSTGRES_DB that aborted
  first-boot init (ON_ERROR_STOP); compose passes APP_DB_PASSWORD;
  microservices init.sql mount annotated schema-only (POSTGRES_USER:
  appuser would collide with CREATE USER); Dockerfile-redis healthcheck
  now authenticates via REDISCLI_AUTH read from redis.conf (plain
  redis-cli ping gets NOAUTH against requirepass - same class as the
  compose sibling eb5e4397 already fixed); dev-container dev/dev creds
  annotated local-only
- 19.3: Grafana admin password 'admin' sat directly under the newly added
  security warning -> env-injected like the rest of the stack
2026-06-10 12:06:57 -07:00
yeasy 1cdd3c582a fix(content): harden Docker examples 2026-06-01 10:33:50 -07:00
yeasy bf3107b775 Update MySQL 8.0 to 8.4 LTS, fix Trivy tag count 2026-05-02 15:22:58 +00:00
Baohua Yang 347c38e8bc Fix naming of the chapter dir 2026-02-22 12:42:15 -08:00