-
Notifications
You must be signed in to change notification settings - Fork 1.3k
hack: update test dockerfiles to buildkit #666
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
Conversation
The main issue atm is that although the new dockerfile allows getting fast incremental builds, multi-platform releases of everything and integration test image very quickly there is no way to quickly run that image with privileges like the tests require. Only docker currently can do that, but docker does not have support for releasing the multi-arch release images needed in CI. The options are: Tend to think |
|
||
# Rootless mode. | ||
# Still requires `--privileged`. | ||
FROM tonistiigi/buildkit:rootless-base AS rootless |
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.
what's this?
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.
Its the rootless-base
stage that built for all platforms so we can use cross-compilation on top of it. I can add a build arg to switch between this image and direct stage. eg. https://github.com/tonistiigi/copy/blob/master/Dockerfile#L3
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.
btw, rootlesskit multi-platform is currently blocked with moby/datakit#638
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.
wow, didn't notice rootlesskit was vendoring datakit
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.
why do we need the copy
binary for rootless
?
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.
Only if node can run apk
an all platforms. What travis can't. The difference is that tonistiigi/buildkit:rootless-base
is already multi-platform so any node can add the missing binaries on top of that.
Also, FROM --platform=$TARGETPLATFORM alpine AS rootless-base
is the same as FROM alpine AS rootless-base
.
# docker run --rm mplatform/mquery tonistiigi/buildkit:rootless-base
Image: tonistiigi/buildkit:rootless-base
* Manifest List: Yes
* Supported platforms:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64/undefined
- linux/ppc64le
- linux/s390x
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.
What travis can't.
Doesn't qemu-user binfmt work on Travis?
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.
Emulation is not that stable that we could trust it in here. Especially on power/s390x. Also, I'd expect this script to run anywhere, without requiring special setup or a new kernel.
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.
(haven't really tested if emultaion works at all on travis)
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.
Could you add the following stuff to the comment lines of the Dockerfile:
- image digest for reproducibility
- how you built the image
- background (can be just a link to this GitHub issue thread)
RUN apk add --no-cache git | ||
|
||
# xgo is a helper for golang cross-compilation | ||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:golang AS xgo |
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.
where's dockerfile for xx?
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.
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only | ||
ARG BUILDKIT_TARGET=buildkitd | ||
ARG REGISTRY_VERSION=2.6 | ||
ARG ROOTLESSKIT_VERSION=20b0fc24b305b031a61ef1a1ca456aadafaf5e77 |
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.
d843aadf00d72082fd7a31572ef018d1e792535f
FROM git AS runc-src | ||
ARG RUNC_VERSION | ||
WORKDIR /usr/src | ||
RUN git clone git://github.com/opencontainers/runc.git runc \ |
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.
Can we experiment ADD git://
source op?
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.
Maybe FROM git://
?
does nightly dind work? |
@AkihiroSuda With option |
COPY --from=binaries / /usr/bin/ | ||
COPY . . | ||
|
||
FROM rootless |
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.
delete this stage (duplicate)
6186adb
to
9487c77
Compare
2e1ee93
to
b59fa55
Compare
ef186c1
to
714ca48
Compare
@AkihiroSuda Something really strange going on with rootless worker here that maybe you can look into. The new integration test image is based on stretch and it seems impossible to get it to pass before a timeout is reached. The data in https://gist.github.com/tonistiigi/a6f95f2527c8f284c3efa61bc8b4a972 |
This is because of
|
Could be some weird difference across Alpine |
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.
LGTM
Mergeable? |
@AkihiroSuda No, I'll still try to get rid of the alpine commit so we don't need to have two stacks of go. |
714ca48
to
a962f8a
Compare
@AkihiroSuda @tiborvass Ready now |
case ${1:-} in | ||
'') | ||
. $(dirname $0)/util | ||
gogo_version=$(awk '$1 == "github.com/gogo/protobuf" { print $2 }' vendor.conf) | ||
case $buildmode in | ||
"buildkit") | ||
buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --frontend-opt build-arg:GOGO_VERSION=$gogo_version --frontend-opt filename=./hack/dockerfiles/generated-files.buildkit.Dockerfile | ||
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --frontend-opt build-arg:GOGO_VERSION=$gogo_version --frontend-opt filename=./hack/dockerfiles/generated-files.buildkit.Dockerfile |
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.
$progressFlag
should also go to docker build
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.
CONTINUOUS_INTEGRATION
is only set with buildctl
rm $tmpfile | ||
;; | ||
*) | ||
case $buildmode in |
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 don't understand this case $buildmode
within the *)
of a case $buildmode
. Bad refactoring or am I missing something?
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.
the *
case is longer than inner switch
ARG ROOTLESS_BASE_MODE=external | ||
|
||
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only | ||
ARG BUILDKIT_TARGET=buildkitd |
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.
duplicate
a962f8a
to
e10477b
Compare
hack/binaries
Outdated
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi | ||
|
||
binariesLegacy() { | ||
mkdir -p bin |
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.
indentation seems broken.
I'm not sure whether there is gofmt
-equivalent for bash, but emacs can indent shell scripts with C-x h M-x indent
.
@@ -154,7 +155,8 @@ FROM buildkit-buildkitd AS rootless | |||
RUN apk add --no-cache shadow shadow-uidmap \ | |||
&& useradd --create-home --home-dir /home/user --uid 1000 user \ | |||
&& mkdir -p /run/user/1000 /home/user/.local/tmp /home/user/.local/share/buildkit \ | |||
&& chown -R user /run/user/1000 /home/user | |||
&& chown -R user /run/user/1000 /home/user \ | |||
&& rm /bin/su && ln -s /bin/busybox /bin/su |
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.
Probably, we can just lock the root with passwd -l root
: https://github.com/genuinetools/img/blob/151b4506829bd7f52f5ba83aa99a3fd08709554a/Dockerfile#L53
Signed-off-by: Tonis Tiigi <[email protected]>
Signed-off-by: Tonis Tiigi <[email protected]>
e10477b
to
43bd294
Compare
Signed-off-by: Tonis Tiigi [email protected]