Repository navigation
Let BuildKit fetch the sources with ADD (The Docker Way) - #841
Dummgelaufen007 wants to merge 3 commits into
Conversation
| ARG LDFLAGS="-Wl,-z,relro,-z,now" | ||
|
|
||
| # retry dns and some http codes that might be transient errors | ||
| ARG WGET_OPTS="--tries=10 --connect-timeout=10 --retry-connrefused --retry-on-host-error --retry-on-http-error=429,500,502,503,504" |
There was a problem hiding this comment.
What is the behavior add ADD in these cases?
There was a problem hiding this comment.
BuildKit's HTTP source does not retry a failed download; the PR text says so under limits. The retry helper in BuildKit (retryhandler/retry.go) is used only by the registry resolver and auth provider, not by source/http/source.go. A transient error fails the build step; a rerun picks up the already cached downloads.
| ARG WGET_OPTS="--tries=10 --connect-timeout=10 --retry-connrefused --retry-on-host-error --retry-on-http-error=429,500,502,503,504" | ||
|
|
||
| # --no-same-owner as we don't care about uid/gid even if we run as root. fixes invalid gid/uid issue. | ||
| ARG TAR_OPTS="--no-same-owner --extract --file" |
There was a problem hiding this comment.
What is the behavior add ADD in this case?
There was a problem hiding this comment.
ADD --unpack extracts with BuildKit's own untar. It sets owner UID/GID only when --chown is given; otherwise no chown options are passed (unpack.go, ChownOpts only when a user is set).
| @@ -1,3 +1,4 @@ | |||
| # syntax=docker/dockerfile:1 | |||
There was a problem hiding this comment.
Does syntax version include what protocols ADD support etc? when was this released as stable?
There was a problem hiding this comment.
docker/dockerfile:1 pulls the latest stable 1.x frontend, independent of the local Docker version (reference, syntax). The minimum versions per flag are listed in the ADD reference: --keep-git-dir 1.1, --checksum 1.6, --unpack 1.17. 1.17.0 was released as stable on 2025-06-17 (release).
| git clone "$X264_URL" && cd x264 && \ | ||
| git checkout --recurse-submodules $X264_VERSION && \ | ||
| cd x264 && \ | ||
| git fetch --unshallow --filter=tree:0 origin +refs/heads/master:refs/remotes/origin/master && \ |
There was a problem hiding this comment.
Not sure i followed why this fetch was needed, ADD does not checkout properly?
There was a problem hiding this comment.
The checkout is fine, but ADD fetches only the commit. x264's version.sh counts the commits of HEAD and of origin/master..HEAD (version.sh#L10-L12), so without the full history and origin/master the version string changes. The fetch restores both; --filter=tree:0 keeps it to commits only. The resulting version string matches a full clone.
b735df2 to
24f71d6
Compare
# Conflicts: # Dockerfile
# Conflicts: # Dockerfile
Let BuildKit fetch the sources with ADD (The Docker Way)
Each recipe names its source in one
ADDline above itsRUN, next to itsARGs and bump lines. Docker fetches and checks all sources at the start of the build, so a broken source stops the build in its first seconds instead of after the steps before it.How BuildKit fetches a source
This PR adds
# syntax=docker/dockerfile:1as first line, so BuildKit fetches the current Dockerfile frontend instead of using the one built into the local Docker;ADD --unpackbelow needs syntax 1.17 (ADD).ADD --checksum=<hash> <url> <dest>downloads a file and checks it;--unpack=trueextracts it. A git URL (git://or ending in.git) with#<commit>is fetched as a checkout of that single commit and checked against it. NoADDsource depends on an earlier step, so BuildKit fetches them all at once when the build starts.What changes in the Dockerfile
Archives.
wget,sha256sumandtarbecome one line; libaribb24 now entersaribb24-*, the directory inside its archive.Git sources.
git cloneandgit checkoutbecome anADDinto the directory the recipe already enters.ADD --checksum=$LIBGME_COMMIT $LIBGME_URL#$LIBGME_COMMIT /game-music-emux264 and uavs3d count their git history for their version string (x264, uavs3d), so they keep
.gitand fetch the history before building; the version string stays the same.libmodplug and opencore-amr now use the same sourceforge link form as lame (
.../download), whichADDfetches reliably.Other lines.
wget,WGET_OPTSandTAR_OPTSgo;curl,tarandgitstay for libjxldeps.sh, x264 and uavs3d.What is given up
wgetdid.ENABLE_FDKAAC.Docker version
This PR leans on newer Docker features:
# syntaxline, forADD --unpack; every build looks the frontend up on Docker Hub.ADDwith a git source at a commit, and--keep-git-dirfor x264 and uavs3d.Tested
A full build with
--no-cachecompleted, including the sanity tests. The x264 and uavs3d version strings match a full clone andversions.jsonlists the commits of all git sources.Research and wording by Claude (Anthropic), directed and reviewed by me.