I’m currently building custom images using the layered Containerfile/Dockerfile from frappe_docker.
In the documentation examples and Dockerfile defaults, FRAPPE_BRANCH is set to version-16. In the Dockerfile, this argument is used both for pulling the base images (frappe/build:${FRAPPE_BRANCH}) and during bench init --frappe-branch=${FRAPPE_BRANCH}.
On Docker Hub, I noticed there are specific tags like v16.x.x in addition to version-16. However, if I pass a specific release tag (like v16.x.x) to FRAPPE_BRANCH:
Will bench init try to clone a git branch named v16.x.x from the Frappe repository?
If GitHub only has the version-16 branch (or specific release tags that might differ), won’t bench init fail?
My goal is to build an image with the latest updates for v16. What is the recommended way to set FRAPPE_BRANCH? Should I stick with version-16, or is there a standard practice for pinning or using release versions in layered builds?
bench init does not require a branch name. Before cloning it runs git ls-remote --heads --tags against the repo and only rejects a value that matches neither - the failure text is literally ‘Invalid branch or tag’ - and the clone itself uses git clone --branch, which checks out a tag in detached state. So FRAPPE_BRANCH=v16.53.0 works for bench init, and it also resolves the FROM lines: frappe/build and frappe/base are published per release tag, not only per branch (v16.53.0 exists on both). One gotcha: the build image for the newest release can lag - base already carries v16.54.0 while build’s newest release tag is v16.53.0 - so confirm the tag exists on both images before pinning. version-16 tracks the rolling branch with the latest fixes but is not reproducible; a tag pins source and base image together. Which matters more for your setup: reproducible rebuilds or always having the newest v16 fixes?
Why does that variable need to be defined twice? Is there a specific reason for this, such as allowing different versions for the build and base images?
The reason FRAPPE_BRANCH is defined twice is simply Docker’s ARG scoping. The first declaration is needed to reference it in the FROM instructions, while the second makes it available inside the build stage, where bench init uses it. Both use the same value, so they don’t select different versions.
And regarding the original question: you don’t necessarily have to use a branch name here. Git tags work as well!
If you just want the latest v16 updates, I’d stick with version-16. That way, you don’t need to worry about updating version numbers manually.
Just be aware of Docker’s build caching! You might want to introduce a CACHE_BUST to ensure that new builds actually fetch the latest repository changes instead of reusing old layers.
Reed: Automated Builds and Deployment | Frappe Docker Docs
Some context on Docker Hub image tags vs. Frappe Git versions:
The frappe/build images mainly provide the required build and runtime dependencies for the corresponding Frappe version. Frappe itself is cloned separately during bench init.
Since you want to follow the latest v16 updates, you can simply stick with the version-16 defaults!
ARG scoping is the whole reason. An ARG declared before the first FROM is global, so it is what every FROM line resolves, but it is out of scope inside a stage body unless that stage redeclares it. In images/layered/Containerfile the first declaration feeds both ‘FROM …/build:${FRAPPE_BRANCH} AS builder’ and the later ‘FROM …/base:${FRAPPE_BRANCH} AS backend’; the second declaration only makes the value visible to bench init --frappe-branch inside the builder stage. So it is not two version knobs - one value drives both image pulls and the git clone. Making them differ means editing the file, and then the base image’s Python packages have to stay aligned with the frappe source you cloned. Re-checked on Docker Hub today: build still tops out at v16.53.0 while base is at v16.54.0, so a single value of v16.54.0 clones fine from git but the builder stage cannot pull its image. Do you build from the shipped Containerfile as-is, or copy it into your own repo where you could give the two FROM lines separate ARGs?
Thanks for the detailed explanation! I’m currently using the shipped Containerfile as-is. Just following up out of curiosity and to learn more about how this works under the hood:
Right now, the build image lags behind the base image by one minor patch. If we pass a specific tag like v16.54.0, the builder stage fails because that tag doesn’t exist yet for build.
However, if we use FRAPPE_BRANCH=version-16, both build:version-16 and base:version-16 on Docker Hub seem to point to their respective latest available image digests (meaning build resolves to v16.53.0 and base resolves to v16.54.0). Is running the build with this minor version mismatch between build and base considered safe/acceptable in practice?
Also, regarding the second FRAPPE_BRANCH redeclaration inside the builder stage: since it’s passed to bench init --frappe-branch, passing version-16 tells Git to pull the tip of the version-16 branch (which aligns with the latest released tag commit anyway). Does that mean using version-16 effectively ensures everything pulls the latest available state, whereas passing an explicit release tag only works when all published artifacts happen to be strictly in sync?
Apologies for the slow follow-up — these two questions deserve a proper answer.
The lag itself is generally accepted in practice. In the layered Containerfile the build stage installs your app onto whatever base image the tag resolves to, and the base image mostly carries OS-level dependencies. Those rarely change much between adjacent patch releases, so a build image lagging base by one patch is normal and most people run exactly this without problems. If you want bit-for-bit reproducibility, pin the base by digest rather than by tag so the final image stays fixed even when the floating tags move.
And yes — version-16 floats. Each image’s version-16 tag points at whatever its own pipeline published most recently, and build and base are published by separate jobs, so they can drift apart. Checking Docker Hub today: frappe/build:version-16 resolves to v16.55.0 while frappe/base:version-16 resolves to v16.56.0 — the lag persists even between the floating tags. An explicit release tag only works when both images happen to have published that same version, which is why matching a pinned release across both usually needs a day or two of grace after each release.
Hope that clears it up — out of curiosity, are you pinning to a digest at the moment, or following the floating tags?