Skip to content

Commit dbbd79d

Browse files
bilby91claude
andauthored
useruid: drop unnecessary dockerfile:1.4 frontend directive (#48)
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) <noreply@anthropic.com>
1 parent 398d0c5 commit dbbd79d

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

useruid.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,15 @@ func statOwner(path string) (uid, gid int, ok bool) {
143143
// /etc/passwd and /etc/group directly via awk + sed so it works on
144144
// Debian (shadow tools) and Alpine/BusyBox (no shadow tools) alike —
145145
// no `usermod`/`groupmod`/`getent` runtime dependency.
146+
//
147+
// Intentionally no `# syntax=docker/dockerfile:X` directive: the
148+
// instructions used here (ARG, FROM $ARG, USER, COPY, RUN) are all
149+
// handled by buildkit's built-in frontend, and declaring an external
150+
// frontend forces buildkit to pull `docker/dockerfile:*` from a
151+
// registry before parsing — which hangs indefinitely in environments
152+
// whose registry mirror routes docker.io through a broken upstream.
146153
func generateUIDDockerfile(baseImage, user string, hostUID, hostGID int) string {
147-
return "# syntax=docker/dockerfile:1.4\n" +
148-
"ARG _DEV_CONTAINERS_BASE_IMAGE=" + baseImage + "\n" +
154+
return "ARG _DEV_CONTAINERS_BASE_IMAGE=" + baseImage + "\n" +
149155
"FROM $_DEV_CONTAINERS_BASE_IMAGE\n" +
150156
"USER root\n" +
151157
"ARG _REMOTE_USER=" + user + "\n" +

useruid_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ func TestGenerateUIDDockerfile_ContainsKeyDirectives(t *testing.T) {
5757
t.Errorf("dockerfile missing %q\n--\n%s", want, df)
5858
}
5959
}
60+
// Declaring an external dockerfile frontend forces buildkit to pull
61+
// docker/dockerfile:* before parsing — which hangs in environments
62+
// whose registry mirror routes docker.io through a broken upstream.
63+
// Nothing in this Dockerfile needs a non-builtin frontend.
64+
if strings.Contains(df, "# syntax=") {
65+
t.Errorf("dockerfile must not declare a syntax= frontend; built-in frontend is sufficient\n--\n%s", df)
66+
}
6067
}
6168

6269
func TestUIDReconcileScript_PortableShape(t *testing.T) {

0 commit comments

Comments
 (0)