1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-21 04:20:23 +00:00
ceph-csi/deploy/cephcsi/image/Dockerfile
Niels de Vos 1f09ca26eb build: create /etc/selinux/config in case it is missing
Sometimes the Ceph container images seem to have a broken scriptlet
while installing/updating Ceph packages. It is relatively common for
them to fail when `/etc/selinux/config` does not exist. By ensuring the
file directory and file exist (even if empty), the package installation
or upgrades succeed.

Signed-off-by: Niels de Vos <ndevos@ibm.com>
2023-12-19 13:06:50 +00:00

83 lines
2.2 KiB
Docker

ARG SRC_DIR="/go/src/github.com/ceph/ceph-csi/"
ARG GO_ARCH
ARG BASE_IMAGE
FROM ${BASE_IMAGE} as updated_base
# TODO: remove the following cmd, when issues
# https://github.com/ceph/ceph-container/issues/2034
# https://github.com/ceph/ceph-container/issues/2141 are fixed.
RUN dnf config-manager --disable \
tcmu-runner,tcmu-runner-source,tcmu-runner-noarch,ceph-iscsi,ganesha || true
RUN mkdir /etc/selinux || true && touch /etc/selinux/config
RUN dnf -y update --nobest \
&& dnf -y install nfs-utils \
&& dnf clean all \
&& rm -rf /var/cache/yum
FROM updated_base as builder
LABEL stage="build"
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
COPY build.env /
RUN source /build.env && \
( 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 ) && \
mkdir -p ${GOROOT} && \
curl https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-${GO_ARCH}.tar.gz | tar xzf - -C ${GOROOT} --strip-components=1
# test if the downloaded version of Golang works (different arch?)
RUN ${GOROOT}/bin/go version && ${GOROOT}/bin/go env
RUN dnf -y install --nodocs \
librados-devel librbd-devel libcephfs-devel \
/usr/bin/cc \
make \
git \
&& dnf clean all \
&& rm -rf /var/cache/yum \
&& true
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 updated_base
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
# verify that all dynamically linked libraries are available
RUN [ $(ldd /usr/local/bin/cephcsi | grep -c '=> not found') = '0' ]
ENTRYPOINT ["/usr/local/bin/cephcsi"]