perf: 新增 .dockerignore 大幅缩减 Docker 构建上下文

backend 与 caddy 构建均缺少 .dockerignore,导致每次构建传输数 GB 无用数据
(backend/tmp 上传文件 980M、frontend/node_modules 520M、.git、backups 等),
卡在 transferring context 阶段。

- backend/.dockerignore:排除 tmp/data/bin/logs/api/.env/docs 等,上下文降到几 MB
- 根 .dockerignore(caddy 构建用,context 为仓库根):排除 backend 运行时产物、
  frontend/node_modules、.git、backups 等

附带收益:原 COPY . 会把 .env(含密钥)打进镜像,现已一并排除。
已确认无 //go:embed 依赖被排除目录,不影响编译。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
yml2213
2026-06-29 23:22:07 +08:00
co-authored by Claude Opus 4.8
parent 4f4f71f251
commit 053eea3f8b
2 changed files with 66 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
# 构建只需要 Go 源码(cmd / internal / pkg / migrations / go.mod / go.sum
# 以下均为运行时产物、二进制、密钥与文档,排除后可把构建上下文从 ~1GB 降到几 MB
# 运行时上传文件与临时目录(最大头,~980MB)
tmp/
data/
# 编译产物
bin/
api
*.exe
# 日志
logs/
*.log
# 本地缓存
.git-cache/
# 密钥与环境文件(避免打进构建上下文)
.env
.env.*
# 文档与脚本(构建不需要)
docs/
scripts/
*.md
# 其它
.DS_Store
Dockerfile
.dockerignore