fix(docker): remove build artifacts from image layers - #2095
fix(docker): remove build artifacts from image layers#2095nightcityblade wants to merge 2 commits into
Conversation
Signed-off-by: nightcityblade <nightcityblade@gmail.com>
|
CI follow-up: both Security jobs pass. The only failure is the Discord notification job, whose log reports that DISCORD_WEBHOOK is not defined; this is a repository workflow-secret issue rather than a failure in the Dockerfile change. |
|
Thanks for turning this around so fast. The core-dump part is right — moving that cleanup into the Two problems though, and they're both about layer placement. The The other one is subtler. While you're in there, one more: Putting it all in one layer, with the doctor running before the delete: RUN crawl4ai-setup \
&& playwright install --with-deps chromium \
&& crawl4ai-doctor \
&& mkdir -p /home/appuser/.cache/ms-playwright \
&& cp -r /root/.cache/ms-playwright/chromium-* \
/root/.cache/ms-playwright/chromium_headless_shell-* \
/home/appuser/.cache/ms-playwright/ \
&& chown -R appuser:appuser /home/appuser/.cache/ms-playwright \
&& rm -rf /root/.cache/ms-playwright \
&& find "${APP_HOME}" -maxdepth 1 -type f -name '*.core' -deleteI built that on arm64 and got 9.03GB → 6.46GB. Checked the result too: root cache gone, no Firefox or WebKit, doctor passes during the build, and crawls still work as Last thing — the new test asserts the cleanup lives in the |
|
Thanks for the detailed layer analysis — addressed in 14291fa.
Validation:
I could not rerun the full image build on this machine because its Docker daemon is unavailable. |
Summary
Fixes #2092.
Keep Playwright installation, runtime-cache copying, and root-cache cleanup in one Docker layer so the superseded root-owned browser cache is not committed to the image. Remove QEMU core dumps immediately after
crawl4ai-doctor, before that layer is committed.List of files changed and why
Dockerfile- clean duplicate Playwright data and doctor core dumps in the same layers that create them.deploy/docker/tests/test_security_container_posture.py- enforce both same-layer cleanup guarantees.How Has This Been Tested?
docker buildx build --check --progress plain .— check complete, no warnings found..venv/bin/python -m pytest deploy/docker/tests/test_security_*.py -q— 317 passed, 1 xfailed..venv/bin/black --check --target-version py312 deploy/docker/tests/test_security_container_posture.py— passed..venv/bin/ruff check deploy/docker/tests/test_security_container_posture.py— passed.git diff --check— passed.A full multi-architecture image build was not run locally; the focused posture test verifies that each cleanup remains in the Docker layer that creates its artifact.
Checklist: