forked from ceph/ceph-nvmeof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
154 lines (131 loc) · 4.76 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# syntax = docker/dockerfile:1.4
ARG NVMEOF_SPDK_VERSION \
NVMEOF_TARGET # either 'gateway' or 'cli'
#------------------------------------------------------------------------------
# Base image for NVMEOF_TARGET=cli (nvmeof-cli)
FROM registry.access.redhat.com/ubi9/ubi@sha256:66233eebd72bb5baa25190d4f55e1dc3fff3a9b77186c1f91a0abdb274452072 AS base-cli
ENV GRPC_DNS_RESOLVER=native
ENTRYPOINT ["python3", "-m", "control.cli"]
CMD []
#------------------------------------------------------------------------------
# Base image for NVMEOF_TARGET=gateway (nvmeof-gateway)
FROM quay.io/ceph/spdk:${NVMEOF_SPDK_VERSION:-NULL} AS base-gateway
RUN rpm -vih https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
RUN \
--mount=type=cache,target=/var/cache/dnf \
--mount=type=cache,target=/var/lib/dnf \
dnf install -y python3-rados && \
dnf install -y python3-rbd && \
dnf config-manager --set-enabled crb && \
dnf install -y ceph-mon-client-nvmeof
ENTRYPOINT ["python3", "-m", "control"]
CMD ["-c", "/src/ceph-nvmeof.conf"]
#------------------------------------------------------------------------------
# Intermediate layer for Python set-up
FROM base-$NVMEOF_TARGET AS python-intermediate
RUN \
--mount=type=cache,target=/var/cache/dnf \
--mount=type=cache,target=/var/lib/dnf \
dnf update -y
ENV PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8 \
PIP_NO_CACHE_DIR=off \
PYTHON_MAJOR=3 \
PYTHON_MINOR=9 \
PDM_ONLY_BINARY=:all:
ARG APPDIR=/src
ARG NVMEOF_NAME \
NVMEOF_SUMMARY \
NVMEOF_DESCRIPTION \
NVMEOF_URL \
NVMEOF_VERSION \
NVMEOF_MAINTAINER \
NVMEOF_TAGS \
NVMEOF_WANTS \
NVMEOF_EXPOSE_SERVICES \
BUILD_DATE \
NVMEOF_GIT_REPO \
NVMEOF_GIT_BRANCH \
NVMEOF_GIT_COMMIT \
NVMEOF_SPDK_VERSION \
NVMEOF_CEPH_VERSION \
NVMEOF_GIT_MODIFIED_FILES \
SPDK_GIT_REPO \
SPDK_GIT_BRANCH \
SPDK_GIT_COMMIT \
HUGEPAGES \
HUGEPAGES_DIR
ENV NVMEOF_VERSION="${NVMEOF_VERSION}" \
NVMEOF_GIT_REPO="${NVMEOF_GIT_REPO}" \
NVMEOF_GIT_BRANCH="${NVMEOF_GIT_BRANCH}" \
NVMEOF_GIT_COMMIT="${NVMEOF_GIT_COMMIT}" \
BUILD_DATE="${BUILD_DATE}" \
NVMEOF_SPDK_VERSION="${NVMEOF_SPDK_VERSION}" \
NVMEOF_CEPH_VERSION="${NVMEOF_CEPH_VERSION}" \
NVMEOF_GIT_MODIFIED_FILES="${NVMEOF_GIT_MODIFIED_FILES}" \
SPDK_GIT_REPO="${SPDK_GIT_REPO}" \
SPDK_GIT_BRANCH="${SPDK_GIT_BRANCH}" \
SPDK_GIT_COMMIT="${SPDK_GIT_COMMIT}" \
HUGEPAGES="${HUGEPAGES}" \
HUGEPAGES_DIR="${HUGEPAGES_DIR}"
# Generic labels
LABEL name="$NVMEOF_NAME" \
version="$NVMEOF_VERSION" \
summary="$NVMEOF_SUMMARY" \
description="$NVMEOF_DESCRIPTION" \
maintainer="$NVMEOF_MAINTAINER" \
release="" \
url="$NVMEOF_URL" \
build-date="$BUILD_DATE" \
vcs-ref="$NVMEOF_GIT_COMMIT"
# k8s-specific labels
LABEL io.k8s.display-name="$NVMEOF_SUMMARY" \
io.k8s.description="$NVMEOF_DESCRIPTION"
# k8s-specific labels
LABEL io.openshift.tags="$NVMEOF_TAGS" \
io.openshift.wants="$NVMEOF_WANTS" \
io.openshift.expose-services="$NVMEOF_EXPOSE_SERVICES"
# Ceph-specific labels
LABEL io.ceph.component="$NVMEOF_NAME" \
io.ceph.summary="$NVMEOF_SUMMARY" \
io.ceph.description="$NVMEOF_DESCRIPTION" \
io.ceph.url="$NVMEOF_URL" \
io.ceph.version="$NVMEOF_VERSION" \
io.ceph.maintainer="$NVMEOF_MAINTAINER" \
io.ceph.git.repo="$NVMEOF_GIT_REPO" \
io.ceph.git.branch="$NVMEOF_GIT_BRANCH" \
io.ceph.git.commit="$NVMEOF_GIT_COMMIT"
ENV PYTHONPATH=$APPDIR/__pypackages__/$PYTHON_MAJOR.$PYTHON_MINOR/lib
WORKDIR $APPDIR
#------------------------------------------------------------------------------
FROM python-intermediate AS builder-base
ARG PDM_VERSION=2.7.4 \
PDM_INSTALL_CMD=sync \
PDM_INSTALL_FLAGS="-v --no-isolation --no-self --no-editable" \
PDM_INSTALL_DEV=""
ENV PDM_INSTALL_FLAGS="$PDM_INSTALL_FLAGS $PDM_INSTALL_DEV"
ENV PDM_CHECK_UPDATE=0
# https://pdm.fming.dev/latest/usage/advanced/#use-pdm-in-a-multi-stage-dockerfile
RUN \
--mount=type=cache,target=/var/cache/dnf \
--mount=type=cache,target=/var/lib/dnf \
dnf install -y python3-pip
RUN \
--mount=type=cache,target=/root/.cache/pip \
pip install -U pip setuptools
RUN \
--mount=type=cache,target=/root/.cache/pip \
pip install pdm==$PDM_VERSION
#------------------------------------------------------------------------------
FROM builder-base AS builder
COPY pyproject.toml pdm.lock pdm.toml ./
RUN \
--mount=type=cache,target=/root/.cache/pdm \
pdm "$PDM_INSTALL_CMD" $PDM_INSTALL_FLAGS
COPY . .
RUN pdm run protoc
#------------------------------------------------------------------------------
FROM python-intermediate
COPY --from=builder $APPDIR .