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
Dockerfile: use TARGETPLATFORM #44513
Conversation
a917f3f
to
170e1f6
Compare
170e1f6
to
96c1201
Compare
80a5303
to
02276cd
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.
Ah, crap. Had a review that I didn't commit; comments may be outdated by now (haven't checked)
# runc | ||
FROM base AS runc-src | ||
WORKDIR /usr/src/runc | ||
RUN git init . && git remote add origin "https://github.com/opencontainers/runc.git" |
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.
- Should we start dogfooding dockerfile (labs): implement
ADD <git ref>
buildkit#2799 ?
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.
Good idea, maybe for a follow-up and wait for final release of Dockerfile frontend 1.5?
go build -buildmode=pie -o /build/registry-v2-schema1 github.com/docker/distribution/cmd/registry; \ | ||
;; \ | ||
esac | ||
--mount=type=tmpfs,target=/go/src <<EOT |
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.
Should this use <<-EOT
, if the intent is to remove the first indentation? (we may have to change some spaces to tabs for that)
efc3683
to
0970234
Compare
Dockerfile
Outdated
export CGO_ENABLED=0 | ||
export CGO_ENABLED=$([ "$DOCKER_STATIC" = "1" ] && echo "0" || echo "1") |
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.
Was this still needed? (if so; should we fix the containerd makefile to set it automatically?)
I see there's also a SHIM_CGO_ENABLED
(but not sure if there's anything we need to do with that one); https://github.com/containerd/containerd/blob/e0be97ccee444c06dc1268df5a99ed80c2cfea76/Makefile#L36
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.
Yes needed otherwise ctr is not static and containerd build warns for native builds:
$ docker buildx build --target containerd .
...
#22 [containerd-build 3/3] RUN --mount=from=containerd-src,src=/usr/src/containerd,rw --mount=type=cache,target=/root/.cache <<EOT (set -e...)
#22 0.862 + bin/ctr
#22 1.921 + bin/containerd
#22 3.631 # github.com/containerd/containerd/cmd/containerd
#22 3.631 /usr/bin/ld: /tmp/go-link-508382094/000019.o: in function `New':
#22 3.631 /go/src/github.com/containerd/containerd/vendor/github.com/miekg/pkcs11/pkcs11.go:77: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
#22 3.712 + bin/containerd-stress
#22 4.438 + bin/containerd-shim
#22 4.885 + bin/containerd-shim-runc-v1
#22 5.423 + bin/containerd-shim-runc-v2
#22 5.767 + binaries
#22 DONE 5.9s
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.
Looks like something we should fix in containerd; they added the STATIC=1
make var; I think that one should ideally take care of that automatically.
0970234
to
c60ee82
Compare
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /build/rootlesskit | ||
xx-go build -o /build/rootlesskit-docker-proxy -ldflags="$([ "$DOCKER_STATIC" != "1" ] && echo "-linkmode=external")" ./cmd/rootlesskit-docker-proxy | ||
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /build/rootlesskit-docker-proxy |
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.
(not for this PR); perhaps we should have a xx-verify
utility that looks for an environment variable, so that we can use XX_STATIC=1
and run xx-verify
unconditionally (would save boiler plating in quite some projects now I think) 🤔
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.
Yes sgtm
2a81651
to
7298765
Compare
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
7298765
to
19f3448
Compare
some failures in docker-py; could be some race condition, but posting, as we recently merged some fixes for
|
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, 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.
LGTM
Okay; let's get this one in, thanks! I'll push my cherry-pick PR |
follow-up #43529
Prepare next follow-ups to properly handle cross compilation using
TARGETPLATFORM
global arg.This will optimize build for each components as it doesn't depend anymore on
dev-base
stage with hardcodedlinux/amd64
platform which installs cross packages for all platforms for cross compilation:moby/Dockerfile
Lines 133 to 149 in d6d0e4c
In follow-up remove
CROSS
andDOCKER_CROSSPLATFORMS
arg and cross stages in Dockerfile. It also needs changes in hack scripts.cc @rumpl @vvoland @thaJeztah