-
Notifications
You must be signed in to change notification settings - Fork 961
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
Add docker buildx build to the Makefile to build and push multi-arch docker images #1915
Conversation
@odidev Could you take a look at failure of the build ? https://github.com/fluid-cloudnative/fluid/runs/6862549795?check_suite_focus=true |
And please also fix the DCO issue. https://github.com/fluid-cloudnative/fluid/pull/1915/checks?check_run_id=6862549238 |
d20794e
to
396f612
Compare
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.csi -t ${CSI_IMG}:${GIT_VERSION} | ||
|
||
docker-buildx-init-users: | ||
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache charts/alluxio/docker/init-users -t ${INIT_USERS_IMG}:${GIT_VERSION} | ||
|
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.
Seems that empty line 263 cause
make: *** No rule to make target 'v0.8.0-f665a4f', needed by 'build'. Stop.
Error: Process completed with exit code 2.
docker/Dockerfile.juicefsruntime
Outdated
@@ -16,14 +16,19 @@ RUN apk add --update curl tzdata iproute2 bash libc6-compat vim && \ | |||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | |||
echo "Asia/Shanghai" > /etc/timezone | |||
|
|||
RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-hongkong.aliyuncs.com/public/pkg/helm/helm-v3.0.3-linux-amd64.tar.gz && \ | |||
RUN if [ `uname -m` == "aarch64" ] ; then curl -o helm-v3.0.3-linux-arm64.tar.gz https://get.helm.sh/helm-v3.7.2-linux-arm64.tar.gz && \ |
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.
How about using https://get.helm.sh/helm-v3.0.3-linux-arm64.tar.gz
?
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.
Amended the PR to use helm v3.0.3 for ARM64.
Codecov Report
@@ Coverage Diff @@
## master #1915 +/- ##
==========================================
+ Coverage 53.50% 53.53% +0.02%
==========================================
Files 285 285
Lines 20387 20387
==========================================
+ Hits 10908 10914 +6
+ Misses 8307 8304 -3
+ Partials 1172 1169 -3
Continue to review full report at Codecov.
|
docker/Dockerfile.application
Outdated
@@ -16,14 +16,19 @@ RUN apk add --update curl tzdata iproute2 bash libc6-compat vim && \ | |||
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | |||
echo "Asia/Shanghai" > /etc/timezone | |||
|
|||
RUN curl -o helm-v3.0.3-linux-amd64.tar.gz http://aliacs-k8s-cn-hongkong.oss-cn-hongkong.aliyuncs.com/public/pkg/helm/helm-v3.0.3-linux-amd64.tar.gz && \ | |||
RUN if [ `uname -m` == "aarch64" ] ; then curl -o helm-v3.0.3-linux-arm64.tar.gz https://get.helm.sh/helm-v3.0.3-linux-arm64.tar.gz && \ |
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 you can use TARGETARCH
instead of run uname -m
in dockerfile, refer to https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope.
An example for reference: https://github.com/juicedata/juicefs-csi-driver/blob/master/Dockerfile#L41
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.
TARGETARCH works well while using docker buildx build. But normal docker build fails to detect TARGETARCH in the RUN clause and thus the helm tar file in the Dockerfiles isn’t getting curled. I have observed the same on both ARM64 and AMD64 platforms with docker build.
Step 4/4 : RUN curl -o helm-v3.0.3-linux-${TARGETARCH}.tar.gz https://get.helm.sh/helm-v3.0.3-linux-${TARGETARCH}.tar.gz && tar -xvf helm-v3.0.3-linux-${TARGETARCH}.tar.gz && mv linux-${TARGETARCH}/helm /usr/local/bin/ddc-helm && chmod u+x /usr/local/bin/ddc-helm && rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz
---> Running in 4aeeac5ded68
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 215 100 215 0 0 817 0 --:--:-- --:--:-- --:--:-- 817
tar: invalid tar magic
The command '/bin/sh -c curl -o helm-v3.0.3-linux-${TARGETARCH}.tar.gz https://get.helm.sh/helm-v3.0.3-linux-${TARGETARCH}.tar.gz && tar -xvf helm-v3.0.3-linux-${TARGETARCH}.tar.gz && mv linux-${TARGETARCH}/helm /usr/local/bin/ddc-helm && chmod u+x /usr/local/bin/ddc-helm && rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz' returned a non-zero code: 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.
add ARG TARGETARCH
in dockerfile and have a try? It works well in this way.
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 have already used ARG TARGETARCH
in my Dockerfiles but was still facing the same issue.
Actually, in docker build, we need to specify flag --build-arg TARGETARCH=amd64
along with docker build command to use TARGETARCH in Dockerfile.
$ sudo docker build --build-arg TARGETARCH=amd64 -f docker/Dockerfile.application -t <NAME> .
I will amend the PR to use --build-arg
flag with docker build commands.
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.
Misunderstood. I think we can explicitly add --build-arg
in docker build commands and make dockerfile more clear. What do you think @cheyang ?
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.
Sure. I also prefer --build-arg
to make the dockerfile easy to understand.
I have amended the PR. Kindly have a look and suggest. |
@@ -165,22 +176,22 @@ update-api-doc: | |||
|
|||
# Build the docker image | |||
docker-build-dataset-controller: generate gen-openapi fmt vet | |||
docker build --no-cache . -f docker/Dockerfile.dataset -t ${DATASET_CONTROLLER_IMG}:${GIT_VERSION} | |||
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.dataset -t ${DATASET_CONTROLLER_IMG}:${GIT_VERSION} |
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 you set default value amd64
for ARCH
in front ?
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.
Sure, added.
Makefile
Outdated
|
||
docker-build-all: ${DOCKER_BUILD} | ||
docker-push-all: ${DOCKER_PUSH} | ||
docker-buildx-all: ${DOCKER_BUILDX} |
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.
When building multi-platform images using buildx, we need to create a builder for it, refer to https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images
I think docker-buildx-all
better to add the whole process.
Furthermore, maybe name docker-buildx-all-push
is more suitable for it.
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.
Docker buildx uses qemu emulation to build images for other platforms than the host.
I already have docker installed on my system. When I built multi-arch images, I simply had to run qemu emulation before using docker buildx, as below:
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
$ docker buildx build --platform linux/amd64,linux/arm64 …..
You want me to add qemu installation along with the docker buildx commands...am I correct?
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 can manually run qemu emulation in short time. And Let the users know through documentation.
In long time I agree that we can run make docker-buildx-all-push
from scratch. I see the similar implementation in https://github.com/openyurtio/openyurt/blob/master/Makefile#L129-L136 .
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, I agree. We can add a point in how_to_develop.md to run qemu emulation before using docker buildx 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.
Would you mind to rename docker-buildx-all
to docker-buildx-all-push
? I think it's more clear for the developer. 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.
agree
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.
@cheyang Sure, added.
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.
Thanks very much!
…docker images Signed-off-by: odidev <[email protected]>
@odidev Thanks very much for your contribution! |
@cheyang , Thank you for the PR merge. May I know when should we expect the official multi-arch docker images release at dockerhub? |
Hopefully late in June. But we have a blocker that our major runtime If you are interested, could you help on how to support Alluxio (https://github.com/Alluxio/alluxio/blob/master/integration/docker/Dockerfile) on ARM platform. The build scripts are in https://github.com/fluid-cloudnative/fluid/tree/master/tools/alluxio |
Okay. I had raised an issue earlier in Fluid, targeting that the unit tests are failing for Linux/ARM64, and I had attached the failing logs in this issue. |
Signed-off-by: odidev [email protected]
Ⅰ. Describe what this PR does
Add docker buildx build to the Makefile to build and push multi-arch docker images and update the documentation as well.
Ⅱ. Does this pull request fix one issue?
Helps to justify #1337
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
No tests.
Ⅳ. Describe how to verify it
make docker-buildx-all
Ⅴ. Special notes for reviews
N/A