heroku/base-images

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

Closed this issue · 0 comments

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:

cat >/etc/apt/sources.list.d/ubuntu.sources <<EOF
Types: deb
URIs: http://archive.ubuntu.com/ubuntu/
Suites: noble noble-updates
Components: main universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: amd64
Types: deb
URIs: http://security.ubuntu.com/ubuntu/
Suites: noble-security
Components: main universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: amd64
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: noble noble-updates
Components: main universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: arm64
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: noble-security
Components: main universe restricted multiverse
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
Architectures: arm64
EOF

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.