heroku / base-images

Recipes for building the base images for Heroku's stacks
BSD 3-Clause "New" or "Revised" License
267 stars 75 forks source link

Heroku-24: Custom sources list causes APT to pull packages lists for multiple architectures #286

Closed edmorley closed 5 months ago

edmorley commented 5 months ago

Our image setup scripts currently override the default Ubuntu APT sources list, in order to disable some unwanted repositories.

However, the way they currently do this is via a hardcoded sources list, which starting with Heroku-24 now includes entries for both AMD64 and ARM64: https://github.com/heroku/base-images/blob/dc82a80d1ae1ac0579432b5a37123175b6c25514/heroku-24/setup.sh#L9-L37

At first glance one might presume that APT would act sensibly here, and only pull the repo index for the current architecture.

However, it seems APT pulls all indexes, and only takes the current arch into account when actually installing packages.

As such, our customisation to the APT sources causes a wasteful double pull of the indexes:

$ docker run --rm --user root heroku/heroku:24-build.nightly apt-get update
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [90.7 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports noble InRelease [255 kB]
Get:3 http://archive.ubuntu.com/ubuntu noble InRelease [255 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease [89.7 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease [90.7 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble-updates InRelease [89.7 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports noble/universe arm64 Packages [19.0 MB]
Get:8 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [19.3 MB]
Get:9 https://apt.postgresql.org/pub/repos/apt noble-pgdg InRelease [123 kB]
Get:10 https://apt.postgresql.org/pub/repos/apt noble-pgdg/main arm64 Packages [413 kB]
Get:11 http://ports.ubuntu.com/ubuntu-ports noble/main arm64 Packages [1780 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages [1813 kB]
Fetched 43.3 MB in 19s (2272 kB/s)

(note both amd64 and arm64 indexes being downloaded)

GUS-W-15576471.