2020-04-21 06:39:03 +00:00
ARG SRC_DIR = "/go/src/github.com/ceph/ceph-csi/"
ARG GO_ARCH
2020-06-22 13:54:18 +00:00
ARG BASE_IMAGE
2020-04-22 12:00:34 +00:00
FROM ${BASE_IMAGE} as builder
2019-03-20 19:15:51 +00:00
2020-04-21 06:39:03 +00:00
LABEL stage = "build"
2019-11-07 09:55:12 +00:00
2020-04-21 06:39:03 +00:00
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
2019-03-20 19:15:51 +00:00
2020-06-22 10:19:37 +00:00
COPY build.env /
RUN source /build.env && \
2020-08-18 09:47:28 +00:00
( test -n " ${ GO_ARCH } " && exit 0; echo -e "\n\nMissing GO_ARCH argument for building image, install Golang or run: make image-cephcsi GOARCH=amd64\n\n" ; exit 1 ) && \
2020-06-22 10:19:37 +00:00
mkdir -p ${ GOROOT } && \
2020-04-21 06:39:03 +00:00
curl https://storage.googleapis.com/golang/go${ GOLANG_VERSION } .linux-${ GO_ARCH } .tar.gz | tar xzf - -C ${ GOROOT } --strip-components= 1
2020-06-22 15:08:07 +00:00
# test if the downloaded version of Golang works (different arch?)
RUN ${ GOROOT } /bin/go version && ${ GOROOT } /bin/go env
2022-02-04 07:32:34 +00:00
# FIXME: Ceph does not need Apache Arrow anymore, some container images may
# still have the repository enabled. Disabling the repository can be removed in
# the future, see https://github.com/ceph/ceph-container/pull/1990 .
RUN dnf config-manager --disable apache-arrow-centos || true
2020-10-26 07:41:54 +00:00
RUN dnf -y install \
2021-03-10 08:07:06 +00:00
librados-devel librbd-devel \
2020-10-26 07:41:54 +00:00
/usr/bin/cc \
make \
git \
&& true
2020-04-21 06:39:03 +00:00
2020-04-21 13:36:27 +00:00
ENV GOROOT = ${ GOROOT } \
2020-04-21 06:39:03 +00:00
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
2020-04-22 12:00:34 +00:00
FROM ${BASE_IMAGE}
2020-04-21 06:39:03 +00:00
ARG SRC_DIR
LABEL maintainers = "Ceph-CSI Authors" \
2020-04-21 13:36:27 +00:00
version = ${ CSI_IMAGE_VERSION } \
architecture = ${ GO_ARCH } \
2020-04-21 06:39:03 +00:00
description = "Ceph-CSI Plugin"
2020-04-22 12:00:34 +00:00
COPY --from= builder ${ SRC_DIR } /_output/cephcsi /usr/local/bin/cephcsi
2019-03-20 19:15:51 +00:00
2020-05-25 12:24:12 +00:00
# verify that all dynamically linked libraries are available
RUN [ $( ldd /usr/local/bin/cephcsi | grep -c '=> not found' ) = '0' ]
2019-03-20 19:15:51 +00:00
ENTRYPOINT [ "/usr/local/bin/cephcsi" ]