88 Commits
Author SHA1 Message Date
Mike McQuaid 377e4f740b Remove Bubblewrap, use Landlock for Linux sandbox
- Landlock needs no separate executable, installation or `sysctl`
  configuration, so use it as the only Linux sandbox implementation
  rather than an opt-in behind `$HOMEBREW_SANDBOX_LINUX_LANDLOCK`.
- Delete `Sandbox::Bubblewrap`, the `brew setup-sandbox` command and
  the implicit `bubblewrap` dependency, none of which Landlock needs.
- Remove the Bubblewrap-era `Sandbox` API (`ensure_sandbox_installed!`,
  `configure!`, `configuration_commands`, `sandbox_install_command`)
  and its call sites now that no backend needs installing or
  configuring.
- Simplify `brew doctor`'s `check_linux_sandbox` to report the
  Landlock failure reason with the `$HOMEBREW_NO_SANDBOX_LINUX`
  workaround.
2026-08-04 11:55:32 +01:00
Michael Cho 6731f67e83 Dockerfile: add GCC 14 for compiler selection to use
Since Ubuntu 24.04 uses GCC 14 libstdc++, we can build with GCC 14 when
a formula needs it. This avoids some less optimal conditional handling
of build dependencies which is needed when bottling.

The default should still be GCC 13 and will be picked by our
preferred_gcc. We should continue building with default to test more
common case of only installing unversioned gcc/g++ on Ubuntu. Once
enough formulae fail with GCC 13, we can move default to GCC 14.
2026-07-07 12:15:35 -04:00
Mike McQuaidandGitHub 93000a539f Merge branch 'main' into move-to-ubuntu24.04 2026-06-07 11:37:42 +01:00
Mike McQuaid 936f0b2a02 Add Linux Bubblewrap sandbox
- Use `bwrap` to translate shared sandbox rules into rootless
  namespace execution.
- Gate the backend behind `HOMEBREW_SANDBOX_LINUX` while the Linux
  policy is still experimental.
- Keep macOS on its existing `sandbox-exec` path while Linux uses shared
  executable lookup for `bwrap`.
- Auto-install `bubblewrap` from `homebrew/core` when the sandbox is
  enabled and no system or usable brewed binary is found.
- Prefer a usable system `bwrap` from `ORIGINAL_PATHS` over a brewed
  one so distribution-provided binaries are used when available.
- Find brewed `bwrap` from `HOMEBREW_ORIGINAL_BREW_FILE` so integration
  subprocesses still use the Linux sandbox.
- Preserve `Sandbox#run`'s tmpdir cwd inside the `bwrap` namespace and
  suppress Linux PTY thread warnings after sandboxed children exit.
- Expose formula, Homebrew library and Linux runtime paths as read-only
  binds so sandboxed source builds can run with vendored Ruby.
- Keep synthetic test formula installs off the API so sandbox CI does
  not require network during local formula setup.
- Avoid creating optional prefix `var` directories just to configure a
  test sandbox and remove empty Linux bind placeholders after runs.
- Require a working rootless `bwrap` on GitHub Actions and install the
  system `bubblewrap` package before Linux tests run.
2026-05-16 16:27:04 +01:00
Michael Cho 3f95c698e4 Migrate to Ubuntu 24.04 2026-05-09 08:58:42 -04:00
Ruoyu Zhong de045bf739 Dockerfile: set HOMEBREW_* variables
This matches what `brew shellenv` prints and make shell completions work
in containers (and codespaces). Evaluating `brew shellenv` does not work
because `brew shellenv` detects that `PATH` is already correctly set and
thus exits without printing anything.

I don't think `MANPATH` and `INFOPATH` (which are also printed by
`brew shellenv`) are needed in the Dockerfile because `man` and `info`
are not installed in the image.
2026-05-09 01:37:22 +08:00
Mike McQuaid 05635369f9 Improve Docker cache reuse
- Separate cache tags because each architecture can replace a shared
  registry cache and leave the other platform with little useful reuse.
- Pin `homebrew-core` as a build input so its layer can be reused
  across brew-only changes without serving a stale tap after core moves.
- Keep generated Bundler cache files out of the Docker context so local
  development artefacts do not bloat or invalidate image builds.
- Cache apt metadata and downloads because package installs are a
  stable dependency layer and should not repeat avoidable network work.
2026-05-04 09:21:18 +01:00
Ruoyu Zhong cbd36bceef Dockerfile: work around a ShellCheck error
ShellCheck sees Dockerfile as a regular shell script, so it cannot
understand it when the function definition `retry()` comes after the
`RUN` command (it sees it as a single command `RUN retry() ...`). As
this causes a parsing error, it cannot be worked around with a
`# shellcheck disable` comment. Instead, let's add a no-op `:` command
before the function definition, so that ShellCheck can happily parse the
file.
2026-05-03 21:27:02 +08:00
Ruoyu Zhong 520dc06d61 Dockerfile: do not let apt-get update errors slip through
When `apt-get update` fails to fetch from a repository due to a
transient network error, its default behavior is to issue a warning and
continue [^1]. When the git-core PPA is unavailable (which is currently
the case due to an ongoing DDoS incident), this causes `apt-get install`
to install an outdated version of `git` from the default Ubuntu
repositories.

To avoid this, let's set `--error-on=any` for `apt-get update`, which
causes it to error out on such transient network errors [^2]. This
option is available since Ubuntu 21.04 and is equivalent to the APT
option `APT::Update::Error-Mode=any` [^3].

See below how `--error-on=any` turns the warning into an error:

    linuxbrew@c557e2acccfe:~$ sudo apt-get update
    Hit:1 https://cli.github.com/packages stable InRelease
    Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease
    Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease
    Hit:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
    Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Err:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
      Could not connect to ppa.launchpadcontent.net:443 (185.125.190.80), connection timed out
    Reading package lists... Done
    W: Failed to fetch https://ppa.launchpadcontent.net/git-core/ppa/ubuntu/dists/jammy/InRelease  Could not connect to ppa.launchpadcontent.net:443 (185.125.190.80), connection timed out
    W: Some index files failed to download. They have been ignored, or old ones used instead.
    linuxbrew@c557e2acccfe:~$ sudo apt-get update --error-on=any
    Hit:1 https://cli.github.com/packages stable InRelease
    Hit:2 http://archive.ubuntu.com/ubuntu jammy InRelease
    Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease
    Hit:4 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
    Hit:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Ign:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
    Err:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease
      Could not connect to ppa.launchpadcontent.net:443 (185.125.190.80), connection timed out
    Reading package lists... Done
    E: Failed to fetch https://ppa.launchpadcontent.net/git-core/ppa/ubuntu/dists/jammy/InRelease  Could not connect to ppa.launchpadcontent.net:443 (185.125.190.80), connection timed out
    E: Some index files failed to download. They have been ignored, or old ones used instead.

[^1]: https://github.com/Debian/apt/blob/6b128124271e94bdb0f4e7850d9286170d712b04/apt-pkg/update.cc#L136-L139
[^2]: https://manpages.debian.org/trixie/apt/apt-get.8.en.html
[^3]: https://lists.ubuntu.com/archives/ubuntu-devel/2021-February/041374.html
2026-05-03 20:35:30 +08:00
Ruoyu Zhong 2aece26170 Dockerfile: fail after all retry attempts fail 2026-05-03 20:35:16 +08:00
Patrick Linnane 8c292b78b8 Dockerfile: retry add-apt-repository
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-05-02 10:03:51 -07:00
Michael Cho 0ec9be5a7a Dockerfile: remove g++-12 from Ubuntu 24.04 2026-02-22 14:23:52 -05:00
Patrick Linnane 7997c6c499 Dockerfile: use double quotes
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-10-08 09:22:54 -07:00
Patrick Linnane d2f8176145 Dockerfile: use exponential backoff
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-10-08 09:18:04 -07:00
Patrick Linnane e354c5130f Dockerfile: retry apt-get
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2025-10-08 08:55:35 -07:00
2ec42b2b92 Dockerfile: install g++-12 and skopeo at same time
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2025-09-16 12:34:39 -04:00
Michael Cho b9297dcdfc Migrate Linux CI to GCC 12 2025-09-14 21:12:55 -04:00
Mike McQuaid ca65389584 Dockerfile: autoformat.
When I was working on this in VSCode with auto-formatting enabled: it
wanted to make these changes which seem nicer to let's let it.
2025-04-01 11:35:43 +01:00
Carlo CabreraandCarlo Cabrera 4510333e9a Dockerfile: skip git-core PPA on arm64 Linux
This seems to be broken on Ubuntu 22.04 at the moment. The system seems
to ship a reasonably modern version (2.34.1), so I think we can make do
with that for now.
2025-03-18 16:56:44 +08:00
Carlo Cabrera 04b89c0ff7 Dockerfile: fix style failure
See https://www.shellcheck.net/wiki/SC2174.
2024-09-06 22:49:18 +08:00
Carlo Cabrera 603f45a97f Dockerfile: align gh installation with upstream documentation
The commands to install `gh` were changed in cli/cli#8693.

We should align what we do there to make what's happening here a bit
more transparent.
2024-09-06 22:42:05 +08:00
Andrei Neculau bc8c7a2a16 docker: revert back linuxbrew's UID to 1000
In https://github.com/Homebrew/brew/pull/17584 we have changed "linuxbrew" user's UID/GID to 1001 in order to mitigate for Ubuntu 23.04 and higher, which started creating a default "ubuntu" user taking over UID/GID 1000 .

While we may desire a deterministic UID in the homebrew docker image, the change effectively modified the behaviour for all current 3 images based on Ubuntu 18.04 20.04 and 22.04 by changing the linuxbrew's user UID/GID from 1000 to 1001. As per https://hub.docker.com/u/homebrew, we do not currently publish an image for 24.04 which the change is mitigating for.

Rather than mitigating for indeterministic behaviour of upstream changes, this commit implements the workaround in https://bugs.launchpad.net/cloud-images/+bug/2005129 to delete the default "ubuntu" user.
2024-07-09 21:29:49 +02:00
Marcos Lilljedahl d542f795bb ci: improve Dockerfile to make proper use of build cache
Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
2024-06-30 21:42:07 -03:00
Bo Anderson 9872572688 Dockerfile: drop libz-dev 2024-05-17 12:33:31 +01:00
Bo Anderson 489879ff72 Enable Ruby 3 for all users 2023-11-29 15:30:17 +00:00
Bo Anderson 54abce335e Dockerfile: set XDG_CACHE_HOME to fix umask in GitHub Actions 2023-11-21 23:44:16 +00:00
Bo AndersonandGitHub 189d709c41 Merge pull request #16241 from Bo98/ruby3-developers
Enable Ruby 3 for `HOMEBREW_DEVELOPER` and the Docker image
2023-11-21 23:40:31 +00:00
Bo Anderson 559336c771 Enable Ruby 3 for HOMEBREW_DEVELOPER 2023-11-20 20:04:18 +00:00
Bo Anderson 9c1c116804 Dockerfile: fix default umask 2023-11-20 18:54:58 +00:00
Bo Anderson 3b1c171184 Further split up Gemfile into groups 2023-09-27 17:33:44 +01:00
Bo Anderson 623eeb4e47 cmd/update-report: tweak messages for CI 2023-07-07 21:10:21 +01:00
Bo Anderson 8d1aabba81 tap: warn if tapping core taps under API mode 2023-07-05 21:57:00 +01:00
Carlo Cabrera 51cdf49c47 Dockerfile: set umask in common-session-noninteractive too
See #15505.
2023-06-05 13:39:42 +08:00
Carlo Cabrera 86390348ac Dockerfile: set default umask
This makes sure that the system `umask` is the same as the one on macOS.

Fixes Homebrew/homebrew-core@155e3ab5a8.
2023-06-01 13:58:33 +08:00
Carlo Cabrera e392bbc0e2 Install gh from GitHub Debian repository 2023-04-21 18:01:08 +08:00
Carlo Cabrera 40d5ba577f Dockerfile: install gh from Homebrew
apt installs an ancient `gh` that is missing some important flags. In
particular, we probably do want the `--match-head-commit` flag for the
extra security it gives us.
2023-04-21 17:32:42 +08:00
Mike McQuaid 6a77ef2170 docker: stop building Ubuntu 16.04 image.
This is too slow to be building every time and we're long past the
deprecation date.

Fixes https://github.com/Homebrew/brew/issues/14661
2023-03-24 08:57:48 +00:00
Sebastian Pipping 05319c86dc Dockerfile: Install gpg (GnuPG 2.x) for Ubuntu 18 and 20 also 2023-03-24 05:42:33 +01:00
Sebastian Pipping 51f171e506 Dockerfile: Fix the build, package gh exists in Ubuntu >=22 only 2023-03-23 20:38:08 +01:00
Carlo Cabrera 3b044a8113 Fix brew style 2023-03-16 01:19:54 +08:00
ff285217da Use --no-install-recommends
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-03-16 01:09:20 +08:00
Carlo Cabrera 60b1cb7afd Dockerfile: remove bash-ism 2023-03-16 01:07:19 +08:00
Carlo Cabrera 9ad7f91801 Dockerfile: fix installation of gh, et al.
Needed for Homebrew/homebrew-core#125556.
2023-03-16 00:44:18 +08:00
Mike McQuaid ed38bf1061 Dockerfile: fix build of Ubuntu 18.04 image.
Some of these packages are only available on newer versions.
2023-03-14 12:25:00 -04:00
Mike McQuaid b43523c81f Dockerfile: apt-get install more useful things
We need all of these in various homebrew/core workflows.
2023-03-14 06:53:02 -04:00
Mike McQuaid 08644386e1 Dockerfile: cleanup style, add comments. 2022-12-13 11:37:05 +00:00
Bo Anderson 8b6fbbaa2b Dockerfile: install acl 2022-12-03 05:31:37 +00:00
Bo Anderson 2acabcae0d Dockerfile: install gpg 2022-11-30 19:16:06 +00:00
Mike McQuaid 6990e5f537 Dockerfile: install jq.
It's a small dependency and makes it easier to do scripting.
2022-11-09 15:32:12 +00:00
Bo Anderson 3ddcf765d2 workflows/docker: base homebrew/brew on 22.04
Also disable fail-fast so that if a image upload fails we don't stop the other uploads halfway.
2022-04-28 21:21:40 +01:00