Peng Ding commited on
Commit
13e00d9
Β·
1 Parent(s): 4bc4d92

fix: add .dockerignore and Docker safety CI

Browse files

- Create .dockerignore excluding .env, credentials, and secrets
- Add docker-safety.yml CI to validate on every Dockerfile change

.dockerignore ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── Secrets & credentials (CRITICAL) ──────────────────
2
+ .env
3
+ .env.*
4
+ .envrc
5
+ *.key
6
+ *.pem
7
+ *.p12
8
+ credentials*
9
+ service-account*
10
+
11
+ # ── Git ───────────────────────────────────────────────
12
+ .git/
13
+ .gitignore
14
+
15
+ # ── AI coding agents ─────────────────────────────────
16
+ .claude/
17
+ .opencode/
18
+ .codex/
19
+ CLAUDE.md
20
+ AGENTS.md
21
+
22
+ # ── Python artifacts ─────────────────────────────────
23
+ __pycache__/
24
+ *.py[codz]
25
+ *.egg-info/
26
+ .venv/
27
+ venv/
28
+ .ruff_cache/
29
+ .mypy_cache/
30
+ .pytest_cache/
31
+
32
+ # ── Misc ─────────────────────────────────────────────
33
+ .github/
34
+ tests/
35
+ *.md
36
+ LICENSE
37
+ Makefile
38
+ .DS_Store
.github/workflows/docker-safety.yml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Docker Safety
2
+
3
+ on:
4
+ push:
5
+ paths:
6
+ - "**/Dockerfile*"
7
+ - "**/*.Dockerfile"
8
+ - ".dockerignore"
9
+ pull_request:
10
+ paths:
11
+ - "**/Dockerfile*"
12
+ - "**/*.Dockerfile"
13
+ - ".dockerignore"
14
+
15
+ jobs:
16
+ docker-safety:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Check .dockerignore exists
22
+ run: |
23
+ if [ ! -f .dockerignore ]; then
24
+ echo "::error::.dockerignore is missing β€” secrets can leak into Docker images"
25
+ exit 1
26
+ fi
27
+
28
+ - name: Check .dockerignore excludes secrets
29
+ run: |
30
+ FAIL=""
31
+ for pattern in ".env" "*.key" "*.pem"; do
32
+ if ! grep -qF "$pattern" .dockerignore; then
33
+ echo "::error::.dockerignore does not exclude '$pattern'"
34
+ FAIL=1
35
+ fi
36
+ done
37
+ [ -z "$FAIL" ] || exit 1
38
+
39
+ - name: Warn on broad COPY/ADD in Dockerfiles
40
+ run: |
41
+ FOUND=$(grep -rnE '^\s*(COPY|ADD)\s+\.\s' **/Dockerfile* Dockerfile* docker/Dockerfile* 2>/dev/null || true)
42
+ if [ -n "$FOUND" ]; then
43
+ echo "::warning::Broad COPY/ADD found (relies on .dockerignore for safety):"
44
+ echo "$FOUND"
45
+ fi
46
+