go-build-template: a Kubernetes makefile with cloud credentials by default
A Makefile/Dockerfile example for Go projects.
At a glance
- What is it?
- A skeleton Go project whose build runs inside a container, publishes images for five architectures through a manifest list, and versions itself from git tags. The defaults are the interesting part, because several of them are inherited rather than chosen.
- Who is it for?
- Use this template when you want a repeatable container build with multi-architecture publishing and are prepared to edit the defaults, because the shipped values are placeholders and one of them is a cloud credential command. Two things to check on day one.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 4 days ago.
- What is it written in?
- Mainly Makefile, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- thockin/go-build-template3,333 ★ · +0
| Repository | 2026-09-24 | 2026-11-22 |
|---|---|---|
| thockin/go-build-template | 3.3k | 3.3k |
0 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The build runs inside a container, with incremental state kept
The central design decision is that you never build on the host. A plain make target invokes Docker's multi-platform builder, which the documentation says you must have installed, and the current directory is mounted into the build so that intermediate state survives between runs. That last part is the reason to accept the arrangement: without the mount, every build starts from nothing, and with it you get the incremental behaviour you would have had from a host toolchain. The cost is stated plainly as well. The template has only been tested on Linux, and the whole thing depends on a container builder being present and configured. Building for every supported architecture is a separate target rather than the default, so the fast path is a single-platform build and the slow path is an explicit choice.
The makefile is inherited from Kubernetes
The first lines of the makefile are a copyright notice from the Kubernetes authors under the Apache licence, dated 2016, which tells you where the logic came from. That heritage shows in a debugging affordance worth knowing about: a variable switches the makefile into a verbose mode where it announces each requested goal and prints the current date, which is exactly what you want when you cannot tell which of forty targets a command actually ran. Left alone, the makefile instead appends a flag that silences recipe echoing, so a normal build prints the commands it runs without the noise of every line being repeated. Both behaviours are three lines of make, and both exist because a makefile this size becomes unreadable the moment it prints everything.
Five platforms by default, and Windows is a comment
The platform list is a single variable with five entries covering the architectures that matter for server workloads: amd64, arm, arm64, ppc64le, and s390x. Beside it there is a comment that is more informative than the list, explaining that Windows could in principle be included but would require base images the template does not ship. That is the whole constraint in one sentence: the base image has to exist for every platform you promise to build, which is why a single-image default would have been simpler and was not chosen. If you add a platform, you have to add a matching base image, and the customising notes say the base image must be a manifest list covering everything in that list.
Version comes from git describe, with a manual alternative commented out
The version string is a variable with two implementations and only one active. The default shells out to the version control system, asking for a description based on tags, falling back to a commit when there is no tag, and appending a marker when the working tree has changed since that tag. Directly underneath sits the alternative, commented out, where you type a number yourself. The container targets use the same source: the image tag is calculated from the most recent tag and the dirty state, with a separate target that shows you what that calculation produced. The consequence is worth understanding before your first release. Git-derived versions mean every commit that builds produces a distinct tag, including builds from a dirty tree, which is helpful locally and awkward in a registry.
Registry credentials default to a cloud token command
Three variables control where images go, and their defaults are placeholders of differing kinds. The registry host is set to an example domain, which is the friendly kind of placeholder: you will notice it immediately. The username defaults to the access-token identity that container registries use for short-lived credentials, which is a reasonable choice but not a universal one. The password is different again, because it is not a value at all but a shell expansion of a command-line tool that prints an access token for the current user. That default is a strong hint about the environment the template was written for, and it is the line to change first, since it assumes a developer machine with that tool authenticated and nothing else.
The base image ships distroless, and the Dockerfile is a template
The default base image is a static build of the distroless distribution, meaning the runtime layer carries no shell and no package manager, which is the modern default for a compiled binary and consistent with the template's own emphasis on a small final image. Two files carry the container definition, and the naming is the detail to notice: the image build file is named with a template suffix rather than being called Dockerfile, and the makefile processes it. The customising notes mention one specific change inside it, that you may need to change or remove the user directive if your process needs to write somewhere or run as a different account. Everything else about the image is left for you to discover, which is a reasonable division given how short the file probably is.
Customising is a short checklist spread over three files
The instructions for adopting the template are a list, and the list is the documentation. In the makefile you set the binary names, replace the placeholder command directories with one per binary, point the registry at your own host, choose between the two version strategies, and optionally change the platform list and the base image. In the image template you adjust or remove the user directive if you need to. In the module file you rename the module path. Two notes complete the picture. The template assumes module-aware builds, which have been the default for Go since a specific release named in the documentation. And the development tooling is isolated in its own sub-module, holding a licence checker and a linter, so if you do not want either of them or their dependencies you can remove that sub-module without touching your application's own requirements.
Editorial conclusion
Use this template when you want a repeatable container build with multi-architecture publishing and are prepared to edit the defaults, because the shipped values are placeholders and one of them is a cloud credential command. Two things to check on day one. Confirm your registry and credentials, since the defaults point at an example host and at a token command from one specific cloud. And decide your version strategy before your first release, because the default derives the version from git describe and that choice is hard to change once images exist.
Frequently asked questions
Can you provide some examples of Go templates?
This repository is one. It is a skeleton Go application whose build is driven by a makefile and packaged by an image definition, shipping two placeholder binaries under a command directory, a package directory, a build directory, and a tools sub-module that holds the licence and lint helpers.
How do you build this Go project?
With make or make build, which runs Docker's multi-platform builder with the current directory mounted into the build so incremental state is kept between runs. Building for every supported architecture is a separate target, Docker's builder must be installed, and the template has only been tested on Linux.
How does the template decide its version?
By default it shells out to the version control system asking for a description based on tags, falling back to a commit identifier, and marking the string when the working tree has changed since the tag. The makefile also contains a commented alternative where the version is typed by hand, and the container target derives the image tag from the same source.
Which platforms does go-build-template support?
Five Linux targets are listed by default, covering amd64, arm, arm64, ppc64le, and s390x. A comment in the makefile notes that Windows could be supported in principle but would need specific base images, which the template does not provide, and the base image must be a manifest list covering every platform in the list.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/thockin-go-build-template)Star history chart for your README
[](https://hysenlabs.com/projects/thockin-go-build-template)Was this useful?