Skip to content

Fix Docker build failure due to stale apt cache - #521

Merged
jwbron merged 1 commit into
mainfrom
egg/fix-dockerfile-apt-cache
Feb 11, 2026
Merged

Fix Docker build failure due to stale apt cache#521
jwbron merged 1 commit into
mainfrom
egg/fix-dockerfile-apt-cache

Conversation

@james-in-a-box

Copy link
Copy Markdown
Contributor

Summary

Fix Docker build failure caused by stale apt package cache, which resulted in 404 errors when trying to install libexpat1 and libexpat1-dev.

The build was failing with:

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/expat/libexpat1_2.4.7-1ubuntu0.7_amd64.deb  404  Not Found
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/expat/libexpat1-dev_2.4.7-1ubuntu0.7_amd64.deb  404  Not Found

Root cause: Docker's layer caching preserved the apt package index from a previous layer, but Ubuntu's mirrors have since removed the old package versions that the cached index referenced.

Fix: Add apt-get update before adding the deadsnakes PPA to ensure base Ubuntu package lists are refreshed before any package installation.

Issue: Fixes release build for #517

Test plan

  • Release build completes successfully
  • Docker image builds and pushes to ghcr.io

Authored-by: egg

Add apt-get update before adding deadsnakes PPA to ensure base Ubuntu
package lists are refreshed. This prevents 404 errors for packages
like libexpat1 that have been updated in Ubuntu's security repository.

The build was failing because Docker cached the apt package index from
the earlier layer, which referenced old package versions (libexpat1
2.4.7-1ubuntu0.7) that are no longer available on the mirrors.

Authored-by: egg

@james-in-a-box james-in-a-box Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Approve

The fix is correct and appropriate for the problem described.

Analysis

Root cause understanding is accurate. When a previous RUN layer has rm -rf /var/lib/apt/lists/* at the end (as lines 31 and 39 do), the next apt-get install requires a fresh apt-get update. The Python 3.11 block was missing this because it assumed add-apt-repository -y would refresh the cache. While add-apt-repository does call apt-get update, it only refreshes the newly-added PPA sources, not the base Ubuntu package lists.

The fix is correct. Adding apt-get update before add-apt-repository ensures:

  1. Base Ubuntu package lists are refreshed (fixing the stale libexpat1 issue)
  2. The subsequent apt-get update after add-apt-repository adds the deadsnakes PPA packages

The comment explains the reasoning well. Future maintainers will understand why there are two apt-get update calls.

Minor observations (not blocking)

  1. Pre-existing: Missing apt cleanup. The Python 3.11 block (lines 46-53) and docker-setup block (lines 60-63) don't have rm -rf /var/lib/apt/lists/* at the end, unlike the earlier RUN blocks. This slightly increases image size but doesn't affect correctness. Not introduced by this PR.

  2. Build caching behavior. This change will bust the cache for all subsequent layers since it modifies an earlier RUN instruction. This is expected and acceptable given the fix is necessary.

— Authored by egg

@james-in-a-box

This comment has been minimized.

@james-in-a-box

Copy link
Copy Markdown
Contributor Author
egg is addressing review feedback...

@jwbron
jwbron merged commit bc7d747 into main Feb 11, 2026
23 checks passed
@james-in-a-box

Copy link
Copy Markdown
Contributor Author

egg feedback addressed. View run logs

1 previous review(s) hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant