-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(packaging/docker): Support multiple architectures #762
Conversation
a3256f3
to
79ad067
Compare
Cleans the grafana/loki-build-image container image, removes unnecessary parts and modularizes it. Switches to alpine for performance and compatibility reasons
Adds multiarch support to the docker build process: - make Dockerfiles multiarch compatible - make Makefile aware (build using `img` in ci, cross-build)
Re-adds docker-cli to loki-build-image, to support TCP daemons
9ee62d7
to
011e3dc
Compare
Okay, this finally comes to an an end here.
Please take a look @slim-bean @cyriltovena @rfratto, thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice job! my only big concerns are two things:
- the regression with systemd headers being removed from the build image due to the switch to alpine
- shouldn't circle CI have picked up the new config.yml and ran some kind of tests against the PR?
If the minimum required version of Docker for building locally changed, it'd be nice to see one of the documents (maybe this one) updated to specify how to build w/ Docker and which version one needs. I wouldn't be surprised if a good amount of people are running macOS so using img directly for building is out of the question |
Wondering if it's possible to centralize the build-image version since we use it in half a dozen docker files and the makefile now, updating it in that many places is certainly prone to error |
Nice work on this @sh0rez there are a lot of details to keep track of here and this is very good, almost there! |
Yeah, done that using build-args and the makefile |
Required for systemd headers
Contrary to what has been done before, this reverts to something close to the old behavior: If a git tag is built, the name of the tag is used as the docker tag. If the master branch is built, it is tagged as master-SHA, master and latest If a regular branch is built, it is not pushed.
75101e9
to
20f4ce8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we got it, LGTM!
✔️ Ready to be merged ✔️
This is take 2 on multiple architectures. It includes the following:
loki-build-image
that is based ongolang:1.11.4-alpine
Dockerfile
forpromtail
that is capable of being built for multiple architectures, based onalpine
Dockerfile
forloki
that is capable of being built for multiple architectures, based onalpine
Makefile
adaptations that allow building theDockerfiles
as cross-platform, but only when run in CICI=true
to trigger the cross-platform runimg
instead ofdocker
under the hood, because of better support for--platform
.build
andpush
the images forloki
andpromtail
foramd64
,arm64
andarmv7
img
andbinfmt-support
Notes
BuildKit
One might have noticed that Docker has introduced a new architecture for building
OCI
container images called BuildKit. It comes with a lot of improvements over the traditionaldocker build
including a DAG-Solver (builds only what's required, parallelizes as much as possible), better caching, frontends (not onlyDockerfile
, dynamic syntax extensions) and especially cross-platform support using--platform
. As long as the host is capable of executing theELF
binaries, BuildKit can build everyarch
binfmt
A Linux kernel feature that allows the kernel to dynamically recognize what to use to execute an
ELF
binary. This is especially useful withbuildkit
andqemu
. By runningsudo docker run --privileged linuxkit/binfmt:v0.6
,qemu-static-ARCH
executors are registered with the kernel and suddenly it is possible to execute aarmhf
/arm64
/ whatever binary as if it was native.img
Although
buildkit
is usable as a standalone daemon, it is a really handy library as well. The awesome folks over at https://github.com/genuinetools/img used this to build a daemonless cli that buildsDockerfiles
using buildkit without root privileges. Because it is still BuildKit, we get all the awesome features above include--platform
.Although BuildKit is going to be fully integrated into Docker Engine in
19.03
, it will still be experimental, so it is easier for the moment to use it standalone.