summaryrefslogtreecommitdiffstats
path: root/container/Containerfile
blob: 7224028723d99c37961846b0edbd5a06c25d0f39 (plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
ARG FROM_IMAGE="quay.io/centos/centos:stream9"
FROM $FROM_IMAGE

# allow FROM_IMAGE to be visible inside this stage
ARG FROM_IMAGE

# Ceph branch name
ARG CEPH_REF="main"

# Ceph SHA1
ARG CEPH_SHA1

# Ceph git repo (ceph-ci.git or ceph.git)
ARG CEPH_GIT_REPO

# (optional) Define the baseurl= for the ganesha.repo
ARG GANESHA_REPO_BASEURL="https://buildlogs.centos.org/centos/\$releasever-stream/storage/\$basearch/nfsganesha-5/"

# (optional) Set to "crimson" to install crimson packages.
ARG OSD_FLAVOR="default"

# (optional) Should be 'true' for CI builds (pull from shaman, etc.)
ARG CI_CONTAINER="true"

# creds for accessing prerelease packages on download.ceph.com for release builds
ARG PRERELEASE_USERNAME ""
ARG PRERELEASE_PASSWORD ""

RUN /bin/echo -e "\
FROM_IMAGE: ${FROM_IMAGE}\n\
CEPH_REF: ${CEPH_REF}\n\
GANESHA_REPO_BASEURL: ${GANESHA_REPO_BASEURL} \n\
OSD_FLAVOR: ${OSD_FLAVOR} \n\
CI_CONTAINER: ${CI_CONTAINER}"

# Other labels are set automatically by container/build github action
# See: https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.authors="Ceph Release Team <ceph-maintainers@ceph.io>" \
      org.opencontainers.image.documentation="https://docs.ceph.com/"

LABEL \
FROM_IMAGE=${FROM_IMAGE} \
CEPH_REF=${CEPH_REF} \
CEPH_SHA1=${CEPH_SHA1} \
CEPH_GIT_REPO=${CEPH_GIT_REPO} \
GANESHA_REPO_BASEURL=${GANESHA_REPO_BASEURL} \
OSD_FLAVOR=${OSD_FLAVOR}


#===================================================================================================
# Install ceph and dependencies, and clean up
# IMPORTANT: in official builds, use '--squash' build option to keep image as small as possible
#   keeping run steps separate makes local rebuilds quick, but images are big without squash option
#===================================================================================================

# Pre-reqs
RUN dnf install -y --setopt=install_weak_deps=False epel-release jq

# Add NFS-Ganesha repo
RUN \
    echo "[ganesha]" > /etc/yum.repos.d/ganesha.repo && \
    echo "name=ganesha" >> /etc/yum.repos.d/ganesha.repo && \
    echo "baseurl=${GANESHA_REPO_BASEURL}" >> /etc/yum.repos.d/ganesha.repo && \
    echo "gpgcheck=0" >> /etc/yum.repos.d/ganesha.repo && \
    echo "enabled=1" >> /etc/yum.repos.d/ganesha.repo

# ISCSI repo
RUN set -x && \
    curl -s -L https://shaman.ceph.com/api/repos/tcmu-runner/main/latest/centos/9/repo?arch=$(arch) -o /etc/yum.repos.d/tcmu-runner.repo && \
    case "${CEPH_REF}" in \
        quincy|reef) \
            curl -s -L https://download.ceph.com/ceph-iscsi/3/rpm/el9/ceph-iscsi.repo -o /etc/yum.repos.d/ceph-iscsi.repo ;\
            ;;\
        main|*) \
            curl -s -L https://shaman.ceph.com/api/repos/ceph-iscsi/main/latest/centos/9/repo -o /etc/yum.repos.d/ceph-iscsi.repo ;\
            ;;\
    esac

# Ceph repo
RUN set -x && \
    rpm --import 'https://download.ceph.com/keys/release.asc' && \
    ARCH=$(arch); if [ "${ARCH}" == "aarch64" ]; then ARCH="arm64"; fi ;\
    IS_RELEASE=0 ;\
    if [[ "${CI_CONTAINER}" == "true" ]] ; then \
        # TODO: this can return different ceph builds (SHA1) for x86 vs. arm runs. is it important to fix?
        REPO_URL=$(curl -s "https://shaman.ceph.com/api/search/?project=ceph&distros=centos/9/${ARCH}&flavor=${OSD_FLAVOR}&ref=${CEPH_REF}&sha1=latest" | jq -r .[0].url) ;\
    else \
        IS_RELEASE=1 ;\
        REPO_URL="https://${PRERELEASE_USERNAME}:${PRERELEASE_PASSWORD}@download.ceph.com/prerelease/ceph/rpm-${CEPH_REF}/el9/" ;\
    fi && \
    rpm -Uvh "$REPO_URL/noarch/ceph-release-1-${IS_RELEASE}.el9.noarch.rpm" ; \
    if [[ IS_RELEASE ]] ; then \
	sed -i "s;http://download.ceph.com/;https://${PRERELEASE_USERNAME}:${PRERELEASE_PASSWORD}@download.ceph.com/prerelease/ceph/;" /etc/yum.repos.d/ceph.repo ; \
	dnf clean expire-cache ; \
    fi


# Copr repos
# scikit for mgr-diskprediction-local
# ref: https://github.com/ceph/ceph-container/pull/1821
RUN \
    dnf install -y --setopt=install_weak_deps=False dnf-plugins-core && \
    dnf copr enable -y tchaikov/python-scikit-learn

# Update package mgr
RUN dnf update -y --setopt=install_weak_deps=False

# Define and install packages
# General
RUN echo "ca-certificates" > packages.txt
# Ceph
# TODO: remove lua-devel and luarocks once they are present in ceph.spec.in
#       ref: https://github.com/ceph/ceph/pull/54575#discussion_r1401199635
RUN echo \
"ceph-common \
ceph-exporter \
ceph-grafana-dashboards \
ceph-immutable-object-cache \
ceph-mds \
ceph-mgr-cephadm \
ceph-mgr-dashboard \
ceph-mgr-diskprediction-local \
ceph-mgr-k8sevents \
ceph-mgr-rook \
ceph-mgr \
ceph-mon \
ceph-osd \
ceph-radosgw lua-devel luarocks \
ceph-volume \
cephfs-mirror \
cephfs-top \
kmod \
libradosstriper1 \
rbd-mirror" \
>> packages.txt

# Optional crimson package(s)
RUN if [ "${OSD_FLAVOR}" == "crimson" ]; then \
    echo "ceph-crimson-osd" >> packages.txt ; \
fi

# Ceph "Recommends"
RUN echo "nvme-cli python3-saml smartmontools" >> packages.txt
# NFS-Ganesha
RUN echo "\
dbus-daemon \
nfs-ganesha-ceph \
nfs-ganesha-rados-grace \
nfs-ganesha-rados-urls \
nfs-ganesha-rgw \
nfs-ganesha \
rpcbind \
sssd-client" >> packages.txt

# ISCSI
RUN echo "ceph-iscsi tcmu-runner python3-rtslib" >> packages.txt

# Ceph-CSI
# TODO: coordinate with @Madhu-1 to have Ceph-CSI install these itself if unused by ceph
#       @adk3798 does cephadm use these?
RUN echo "attr ceph-fuse rbd-nbd"  >> packages.txt

# Rook (only if packages must be in ceph container image)
RUN echo "systemd-udev" >> packages.txt

# Util packages (should be kept to only utils that are truly very useful)
# 'sgdisk' (from gdisk) is used in docs and scripts for clearing disks (could be a risk? @travisn @guits @ktdreyer ?)
# 'ps' (from procps-ng) and 'hostname' are very valuable for debugging and CI
# TODO: remove sg3_utils once they are moved to ceph.spec.in with libstoragemgmt
#       ref: https://github.com/ceph/ceph-container/pull/2013#issuecomment-1248606472
RUN echo "gdisk hostname procps-ng sg3_utils e2fsprogs lvm2 gcc" >> packages.txt

# scikit
RUN echo "python3-scikit-learn" >> packages.txt

# ceph-node-proxy
RUN echo "ceph-node-proxy" >> packages.txt

RUN echo "=== PACKAGES TO BE INSTALLED ==="; cat packages.txt
RUN echo "=== INSTALLING ===" ; \
dnf install -y --setopt=install_weak_deps=False --setopt=skip_missing_names_on_install=False --enablerepo=crb $(cat packages.txt)

# XXX why isn't this done in the ganesha package?
RUN mkdir -p /var/run/ganesha

# Disable sync with udev since the container can not contact udev
RUN \
    sed -i -e 's/udev_rules = 1/udev_rules = 0/' \
           -e 's/udev_sync = 1/udev_sync = 0/' \
           -e 's/obtain_device_list_from_udev = 1/obtain_device_list_from_udev = 0/' \
        /etc/lvm/lvm.conf && \
    # validate the sed command worked as expected
    grep -sqo "udev_sync = 0" /etc/lvm/lvm.conf && \
    grep -sqo "udev_rules = 0" /etc/lvm/lvm.conf && \
    grep -sqo "obtain_device_list_from_udev = 0" /etc/lvm/lvm.conf

# CLEAN UP!
RUN set -x && \
    dnf clean all && \
    rm -rf /var/cache/dnf/* && \
    rm -rf /var/lib/dnf/* && \
    rm -f /var/lib/rpm/__db* && \
    # remove unnecessary files with big impact
    rm -rf /etc/selinux /usr/share/{doc,man,selinux} && \
    # don't keep compiled python binaries
    find / -xdev \( -name "*.pyc" -o -name "*.pyo" \) -delete

# Verify that the packages installed haven't been accidentally cleaned, then
# clean the package list and re-clean unnecessary RPM database files
RUN rpm -q $(cat packages.txt) && rm -f /var/lib/rpm/__db* && rm -f *packages.txt

#
# Set some envs in the container for quickly inspecting details about the build at runtime
ENV CEPH_IS_DEVEL="${CI_CONTAINER}" \
    CEPH_REF="${CEPH_REF}" \
    CEPH_OSD_FLAVOR="${OSD_FLAVOR}" \
    FROM_IMAGE="${FROM_IMAGE}"