Skip to content
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

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 49 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ INIT_USERS_IMG ?= ${IMG_REPO}/init-users
WEBHOOK_IMG ?= ${IMG_REPO}/fluid-webhook
GO_MODULE ?= off
GC_FLAGS ?= -gcflags="all=-N -l"
ARCH ?= amd64

LOCAL_FLAGS ?= -gcflags=-l
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
Expand All @@ -26,10 +27,10 @@ GOBIN=$(shell go env GOBIN)
endif

UNAME := $(shell uname -m)
ifeq ($(UNAME), x86_64)
ARCH := amd64
else
ifeq ($(UNAME), aarch64)
ARCH := arm64
else
ARCH := amd64
endif

CURRENT_DIR=$(shell pwd)
Expand Down Expand Up @@ -73,6 +74,17 @@ DOCKER_PUSH += docker-push-goosefsruntime-controller
DOCKER_PUSH += docker-push-juicefsruntime-controller
DOCKER_PUSH += docker-push-init-users

# Buildx and push docker images
DOCKER_BUILDX_PUSH := docker-buildx-push-dataset-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-application-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-alluxioruntime-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-jindoruntime-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-goosefsruntime-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-csi
DOCKER_BUILDX_PUSH += docker-buildx-push-webhook
DOCKER_BUILDX_PUSH += docker-buildx-push-juicefsruntime-controller
DOCKER_BUILDX_PUSH += docker-buildx-push-init-users

override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
Expand Down Expand Up @@ -165,22 +177,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}
Copy link
Member

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added.


docker-build-application-controller: generate fmt vet
docker build --no-cache . -f docker/Dockerfile.application -t ${APPLICATION_CONTROLLER_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.application -t ${APPLICATION_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-alluxioruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-jindoruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.jindoruntime -t ${JINDORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.jindoruntime -t ${JINDORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-goosefsruntime-controller: generate gen-openapi fmt vet
docker build --no-cache . -f docker/Dockerfile.goosefsruntime -t ${GOOSEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.goosefsruntime -t ${GOOSEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-juicefsruntime-controller: generate gen-openapi fmt vet juicefsruntime-controller-build
docker build --no-cache . -f docker/Dockerfile.juicefsruntime -t ${JUICEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.juicefsruntime -t ${JUICEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-build-csi: generate fmt vet
docker build --no-cache . -f docker/Dockerfile.csi -t ${CSI_IMG}:${GIT_VERSION}
Expand All @@ -192,7 +204,7 @@ docker-build-init-users:
docker build --no-cache charts/alluxio/docker/init-users -t ${INIT_USERS_IMG}:${GIT_VERSION}

docker-build-webhook:
docker build --no-cache . -f docker/Dockerfile.webhook -t ${WEBHOOK_IMG}:${GIT_VERSION}
docker build --no-cache --build-arg TARGETARCH=${ARCH} . -f docker/Dockerfile.webhook -t ${WEBHOOK_IMG}:${GIT_VERSION}

# Push the docker image
docker-push-dataset-controller: docker-build-dataset-controller
Expand Down Expand Up @@ -225,10 +237,37 @@ docker-push-init-users: docker-build-init-users
docker-push-webhook: docker-build-webhook
docker push ${WEBHOOK_IMG}:${GIT_VERSION}

# Buildx and push the docker image
docker-buildx-push-dataset-controller: generate gen-openapi fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.dataset -t ${DATASET_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-application-controller: generate fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.application -t ${APPLICATION_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-alluxioruntime-controller: generate gen-openapi fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.alluxioruntime -t ${ALLUXIORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-jindoruntime-controller: generate gen-openapi fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.jindoruntime -t ${JINDORUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-goosefsruntime-controller: generate gen-openapi fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.goosefsruntime -t ${GOOSEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-juicefsruntime-controller: generate gen-openapi fmt vet juicefsruntime-controller-build
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.juicefsruntime -t ${JUICEFSRUNTIME_CONTROLLER_IMG}:${GIT_VERSION}

docker-buildx-push-csi: generate fmt vet
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.csi -t ${CSI_IMG}:${GIT_VERSION}

docker-buildx-push-init-users:
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache charts/alluxio/docker/init-users -t ${INIT_USERS_IMG}:${GIT_VERSION}

Copy link
Collaborator

@cheyang cheyang Jun 14, 2022

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-buildx-push-webhook:
docker buildx build --push --platform linux/amd64,linux/arm64 --no-cache . -f docker/Dockerfile.webhook -t ${WEBHOOK_IMG}:${GIT_VERSION}

docker-build-all: ${DOCKER_BUILD}
docker-push-all: ${DOCKER_PUSH}
docker-buildx-all-push: ${DOCKER_BUILDX_PUSH}

gen-sdk:
./hack/sdk/gen-sdk.sh
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.alluxioruntime
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/ /charts

Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.application
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/ /charts

Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.dataset
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/ /charts

Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.goosefsruntime
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/ /charts

Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.jindoruntime
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/jindofs /charts/jindofs
ADD charts/jindofsx /charts/jindofsx
Expand Down
11 changes: 6 additions & 5 deletions docker/Dockerfile.juicefsruntime
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ 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 && \
tar -xvf helm-v3.0.3-linux-amd64.tar.gz && \
mv linux-amd64/helm /usr/local/bin/ddc-helm && \
ARG TARGETARCH
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-amd64.tar.gz
rm -f helm-v3.0.3-linux-${TARGETARCH}.tar.gz

ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

ADD charts/ /charts

Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.webhook
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ RUN apk add --update curl tzdata iproute2 bash libc6-compat vim && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone

ARG TARGETARCH
ENV K8S_VERSION v1.14.8
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
RUN curl -o /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl && chmod +x /usr/local/bin/kubectl

COPY --from=builder /go/bin/fluid-webhook /usr/local/bin/fluid-webhook
COPY --from=builder /go/bin/dlv /usr/local/bin/dlv
Expand Down
4 changes: 4 additions & 0 deletions docs/en/dev/how_to_develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ By default, the binary would be put under `<fluid-path>/bin`.

# build all images
$ make docker-build-all

# build and push all images using docker buildx (Run QEMU emulation before docker buildx, as below)
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
$ make docker-buildx-all-push
```
Before running Fluid, you need to push the built image to an accessible image registry.

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/dev/how_to_develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ $ dlv debug --headless --listen ":12345" --log --api-version=2 cmd/alluxio/main.
$ dlv connect "<remote-addr>:12345" --api-version=2
```

> 注意:要进行远程调试,请确保远程主机指定的端口未被占用并且已经对远程主机的防火墙进行了适当的配置
> 注意:要进行远程调试,请确保远程主机指定的端口未被占用并且已经对远程主机的防火墙进行了适当的配置