Add support to build multi architecture image

This is back port fo https://github.com/ceph/ceph-csi/pull/866
to release-v2.1 branch

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2020-04-23 10:18:53 +05:30
committed by Humble Devassy Chirammal
parent 67be05f547
commit bad06a1751
5 changed files with 98 additions and 23 deletions

View File

@ -1,15 +1,51 @@
FROM ceph/ceph:v15
LABEL maintainers="Ceph-CSI Authors"
LABEL description="Ceph-CSI Plugin"
ARG SRC_DIR="/go/src/github.com/ceph/ceph-csi/"
ARG GO_ARCH
ARG BASE_IMAGE=ceph/ceph:v15
# To support cross building, do NOT RUN native binaries here.
# If we have to run native binaries, qemu-user-static must be installed on
# build host and mounted to container.
FROM ${BASE_IMAGE} as builder
# Removing ceph-iscsi repo to workaround the repo issue while upgrading
#RUN rm -f /etc/yum.repos.d/ceph-iscsi.repo && yum -y update && yum clean all
ENV CSIBIN=/usr/local/bin/cephcsi
LABEL stage="build"
COPY cephcsi $CSIBIN
ARG GOLANG_VERSION=1.13.9
ARG CSI_IMAGE_NAME=quay.io/cephcsi/cephcsi
ARG CSI_IMAGE_VERSION=canary
ARG GO_ARCH
ARG SRC_DIR
ARG GIT_COMMIT
ARG GOROOT=/usr/local/go
RUN mkdir -p ${GOROOT} && \
curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GO_ARCH}.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1
RUN dnf install libcephfs-devel librados-devel librbd-devel /usr/bin/cc make -y
ENV GOROOT=${GOROOT} \
GOPATH=/go \
CGO_ENABLED=1 \
GIT_COMMIT="${GIT_COMMIT}" \
ENV_CSI_IMAGE_VERSION="${CSI_IMAGE_VERSION}" \
ENV_CSI_IMAGE_NAME="${CSI_IMAGE_NAME}" \
PATH="${GOROOT}/bin:${GOPATH}/bin:${PATH}"
WORKDIR ${SRC_DIR}
# Copy source directories
COPY . ${SRC_DIR}
# Build executable
RUN make cephcsi
#-- Final container
FROM ${BASE_IMAGE}
ARG SRC_DIR
LABEL maintainers="Ceph-CSI Authors" \
version=${CSI_IMAGE_VERSION} \
architecture=${GO_ARCH} \
description="Ceph-CSI Plugin"
COPY --from=builder ${SRC_DIR}/_output/cephcsi /usr/local/bin/cephcsi
ENTRYPOINT ["/usr/local/bin/cephcsi"]