File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,14 +63,7 @@ RUN apt-get update \
6363 && apt-get upgrade -y --no-install-recommends \
6464 && rm -rf /var/lib/apt/lists/* \
6565 && pip install --no-cache-dir -r requirements.txt \
66- && pip cache purge || true \
67- && groupadd --system --gid 1000 appuser \
68- && useradd --system --uid 1000 --gid appuser --create-home --home-dir /home/appuser --shell /usr/sbin/nologin appuser \
69- && mkdir -p /app/data \
70- && chown -R appuser:appuser /app
71-
72- # 非 root 运行,降低容器逃逸后的主机影响面
73- USER appuser
66+ && pip cache purge || true
7467
7568# 环境变量配置
7669ENV HOST="0.0.0.0" \
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ version: "3"
22services :
33 file-code-box :
44 image : lanol/filecodebox:2.5.3 # x-release-please-version
5- user : " 1000:1000"
65 volumes :
76 - fcb-data:/app/data:rw
87 restart : unless-stopped
Original file line number Diff line number Diff line change @@ -90,13 +90,13 @@ def test_successful_login_does_not_consume_failure_quota(self):
9090 self .assertTrue (ip_limit ["login" ].check_ip ("198.51.100.8" ))
9191
9292
93- class DockerNonRootTests (unittest .TestCase ):
94- def test_dockerfile_runs_as_non_root_user (self ):
93+ class DockerRuntimeUserTests (unittest .TestCase ):
94+ def test_dockerfile_defaults_to_root_for_volume_compatibility (self ):
95+ # 默认 root:兼容已有 data 卷权限;如需非 root 可由编排层自行指定 user
9596 text = Path ("Dockerfile" ).read_text ()
96- self .assertIn ("USER appuser" , text )
97- self .assertIn ("--uid 1000" , text )
97+ self .assertNotIn ("USER appuser" , text )
9898 compose = Path ("docker-compose.yml" ).read_text ()
99- self .assertIn ('user: "1000:1000"' , compose )
99+ self .assertNotIn ('user: "1000:1000"' , compose )
100100
101101
102102if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments