[feature] use buildx to produce multi arch image kubesphere#3683

Signed-off-by: lxm <lxm.xupt@gmail.com>
This commit is contained in:
lxm
2021-04-10 00:06:07 +08:00
parent 6a58572167
commit af536c0c96
11 changed files with 242 additions and 2 deletions

44
build/Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
FROM ubuntu:18.04 as binarydownloader
ARG HELM_VERSION=v3.5.2
ARG KUSTOMIZE_VERSION=v4.0.5
ARG KUBE_VERSION=v1.16.4
ARG ETCD_VERSION=v3.3.11
RUN apt update && apt -y install wget curl
ADD ./hack /opt/hack/
RUN bash /opt/hack/build-scripts/get-helm.sh
RUN bash /opt/hack/build-scripts/get-kustomize.sh
RUN bash /opt/hack/build-scripts/get-etcd.sh
RUN bash /opt/hack/build-scripts/get-kubernetes.sh
FROM golang:1.13 as builder
ADD . /opt/kubesphere/
WORKDIR /opt/kubesphere/
RUN apt update && apt -y install sudo
RUN bash /opt/kubesphere/hack/install_kubebuilder.sh
COPY --from=binarydownloader /usr/local/kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin/kube-apiserver
COPY --from=binarydownloader /usr/local/kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin/kubectl
COPY --from=binarydownloader /usr/local/bin/etcd /usr/local/kubebuilder/bin/etcd
RUN bash -c "source /opt/kubesphere/hack/init_env.sh && make ks-apiserver"
RUN bash -c "source /opt/kubesphere/hack/init_env.sh && make ks-controller-manager"
FROM alpine:3.11 as ks-apiserver
RUN apk add --no-cache ca-certificates
COPY --from=binarydownloader /usr/bin/helm /usr/bin/helm
COPY --from=builder /opt/kubesphere/bin/cmd/ks-apiserver /usr/local/bin/
EXPOSE 9090
CMD ["sh"]
FROM alpine:3.11 as ks-controller-manager
RUN apk add --no-cache ca-certificates
COPY --from=binarydownloader /usr/bin/helm /usr/bin/helm
COPY --from=binarydownloader /usr/bin/kustomize /usr/bin/kustomize
COPY --from=builder /opt/kubesphere/bin/cmd/controller-manager /usr/local/bin/
EXPOSE 8443 8080
CMD ["sh"]