From 940a56ce215175054db4397ec6738a1ab1dd08bd Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Tue, 9 Aug 2022 17:00:24 +0200 Subject: [PATCH] crossbuild: add fix to set ulimit for debian images (#856) Signed-off-by: Florian Lehner --- dev-tools/mage/crossbuild.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 56a6860393b..8a193003ab7 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -281,6 +281,15 @@ func (b GolangCrossBuilder) Build() error { verbose = "true" } var args []string + // There's a bug on certain debian versions: + // https://discuss.linuxcontainers.org/t/debian-jessie-containers-have-extremely-low-performance/1272 + // basically, apt-get has a bug where will try to iterate through every possible FD as set by the NOFILE ulimit. + // On certain docker installs, docker will set the ulimit to a value > 10^9, which means apt-get will take >1 hour. + // This runs across all possible debian platforms, since there's no real harm in it. + if strings.Contains(image, "debian") { + args = append(args, "--ulimit", "nofile=262144:262144") + } + if runtime.GOOS != "windows" { args = append(args, "--env", "EXEC_UID="+strconv.Itoa(os.Getuid()),