From 27d2db16c2e4e771702cde8fb1ed9bf9762ecb5a Mon Sep 17 00:00:00 2001 From: bilby91 Date: Tue, 12 May 2026 18:20:02 -0300 Subject: [PATCH] useruid: drop unnecessary dockerfile:1.4 frontend directive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generated uid_reconcile Dockerfile only uses ARG, FROM $ARG, USER, COPY, and RUN — all handled by buildkit's built-in frontend. The `# syntax=docker/dockerfile:1.4` declaration forced buildkit to pull docker/dockerfile:* from a registry before parsing, which hangs indefinitely in environments whose mirror routes docker.io through a broken upstream (observed on DAP workspaces routing through an ECR docker-hub mirror). Adds a test guard so the directive can't be reintroduced. Co-Authored-By: Claude Opus 4.7 (1M context) --- useruid.go | 10 ++++++++-- useruid_test.go | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/useruid.go b/useruid.go index 3e1e41c..8610c53 100644 --- a/useruid.go +++ b/useruid.go @@ -143,9 +143,15 @@ func statOwner(path string) (uid, gid int, ok bool) { // /etc/passwd and /etc/group directly via awk + sed so it works on // Debian (shadow tools) and Alpine/BusyBox (no shadow tools) alike — // no `usermod`/`groupmod`/`getent` runtime dependency. +// +// Intentionally no `# syntax=docker/dockerfile:X` directive: the +// instructions used here (ARG, FROM $ARG, USER, COPY, RUN) are all +// handled by buildkit's built-in frontend, and declaring an external +// frontend forces buildkit to pull `docker/dockerfile:*` from a +// registry before parsing — which hangs indefinitely in environments +// whose registry mirror routes docker.io through a broken upstream. func generateUIDDockerfile(baseImage, user string, hostUID, hostGID int) string { - return "# syntax=docker/dockerfile:1.4\n" + - "ARG _DEV_CONTAINERS_BASE_IMAGE=" + baseImage + "\n" + + return "ARG _DEV_CONTAINERS_BASE_IMAGE=" + baseImage + "\n" + "FROM $_DEV_CONTAINERS_BASE_IMAGE\n" + "USER root\n" + "ARG _REMOTE_USER=" + user + "\n" + diff --git a/useruid_test.go b/useruid_test.go index 5f16f7b..43d5758 100644 --- a/useruid_test.go +++ b/useruid_test.go @@ -57,6 +57,13 @@ func TestGenerateUIDDockerfile_ContainsKeyDirectives(t *testing.T) { t.Errorf("dockerfile missing %q\n--\n%s", want, df) } } + // Declaring an external dockerfile frontend forces buildkit to pull + // docker/dockerfile:* before parsing — which hangs in environments + // whose registry mirror routes docker.io through a broken upstream. + // Nothing in this Dockerfile needs a non-builtin frontend. + if strings.Contains(df, "# syntax=") { + t.Errorf("dockerfile must not declare a syntax= frontend; built-in frontend is sufficient\n--\n%s", df) + } } func TestUIDReconcileScript_PortableShape(t *testing.T) {