-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile.oraclelinux8
273 lines (231 loc) · 9.79 KB
/
Dockerfile.oraclelinux8
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# syntax=docker/dockerfile:1.4
# This Dockerfile is used for x86 production builds. Oracle Linux 8 comes with glibc 2.28,
# which is supported by all Linux distributions used by Hopsworks: CentOS >=8 and Ubuntu >=20.
# Glibc tends to be backwards compatible, but not forwards compatible.
FROM oraclelinux:8 as rondb-build-dependencies
ARG CMAKE_VERSION=3.23.2
ARG OPEN_SSL_VERSION=3.0.14
ARG GO_VERSION=1.20.3
ARG JSONCPP_VERSION=1.9.5
ARG BOOST_VERSION_MAJOR=1
ARG BOOST_VERSION_MINOR=86
ARG BOOST_VERSION_PATCH=0
ARG AVRO_VERSION=1.12.0
# Default build threads to 1; max is defined in Docker config (run `nproc` in Docker container)
ARG BUILD_THREADS
ENV THREADS_ARG=${BUILD_THREADS:-1}
# RonDB 22.10 use gcc/g++ 10/11/12 for amd64/arm64 respectively.
# We will not remove the default installation, but change the default
# one using software collections (scl).
# To use the required version, the command
# >> source scl_source enable gcc-toolset-12
# is run in the given RUN statement. Unfortunately, this command
# does not persist between RUN statements.
ARG TARGETARCH
COPY <<-"EOF" /etc/yum/repos.d/epel-yum-ol8.repo
[ol8_epel]
name=Oracle Linux $releasever EPEL ($basearch)
baseurl=http://yum.oracle.com/repo/OracleLinux/OL8/developer/EPEL/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
[ol8_codeready_builder]
name=Oracle Linux 8 CodeReady Builder (\$basearch) - Unsupported
baseurl=http://yum.oracle.com/repo/OracleLinux/OL8/codeready/builder/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
EOF
#https://github.com/docker/buildx/issues/379
RUN --mount=type=cache,target=/var/cache/yum,id=oracle8-yum \
yum -y update && \
yum -y install \
wget make git which perl-core openldap-devel \
flex krb5-server krb5-workstation krb5-devel \
numactl numactl-libs numactl-devel \
uuid-devel libudev-devel doxygen\
patchelf ncurses-devel java-1.8.0-openjdk-devel automake \
zlib-devel scl-utils \
vim pigz hostname \
gcc-toolset-12 maven rpcgen
# Building RonDB 24.10 requires bison at least version 3.8. Oracle linux 8 ships
# with a version that is too old, so we have to install manually.
RUN curl -LO https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.gz \
&& echo '06c9e13bdf7eb24d4ceb6b59205a4f67c2c7e7213119644430fe82fbd14a0abb bison-3.8.2.tar.gz' | sha256sum -c - \
&& tar xzf bison-3.8.2.tar.gz \
&& cd bison-3.8.2 \
&& source scl_source enable gcc-toolset-12 \
&& ./configure --prefix=/ \
&& make -j$THREADS_ARG \
&& make install \
&& cd .. \
&& rm -rf bison-3.8.2.tar.gz bison-3.8.2
# Creating a cache dir for downloads to avoid redownloading
ENV DOWNLOADS_CACHE_DIR=/tmp/downloads
RUN mkdir $DOWNLOADS_CACHE_DIR
# RonDB 22.10 requires OpenSSL version 3.0.11 and will look for
# it in $OPENSSL_ROOT. We will not overwrite the system's OpenSSL library,
# but just install the specified version.
# Commands are from https://linuxpip.org/install-openssl-linux/
ENV OPENSSL_ROOT=/usr/local/ssl
ENV OPENSSL_ROOT_DIR=$OPENSSL_ROOT
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
wget -N --progress=bar:force -P $DOWNLOADS_CACHE_DIR \
https://www.openssl.org/source/openssl-${OPEN_SSL_VERSION}.tar.gz \
&& tar xf $DOWNLOADS_CACHE_DIR/openssl-${OPEN_SSL_VERSION}.tar.gz -C . \
&& cd openssl-${OPEN_SSL_VERSION} \
&& source scl_source enable gcc-toolset-12 \
&& ./config --prefix=$OPENSSL_ROOT --openssldir=$OPENSSL_ROOT shared zlib \
&& make -j$THREADS_ARG \
&& make install \
&& echo "$OPENSSL_ROOT/lib64" >> /etc/ld.so.conf.d/openssl-${OPEN_SSL_VERSION}.conf \
&& ldconfig -v \
&& cd .. \
&& rm -rf openssl-${OPEN_SSL_VERSION}
# Installing CMake
# CMake will look for $OPENSSL_ROOT_DIR
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
source scl_source enable gcc-toolset-12 \
&& wget -N --progress=bar:force -P $DOWNLOADS_CACHE_DIR \
https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION.tar.gz \
&& tar xzf $DOWNLOADS_CACHE_DIR/cmake-$CMAKE_VERSION.tar.gz -C . \
&& cd cmake-${CMAKE_VERSION} \
&& ./bootstrap --prefix=/usr/local \
&& make -j$THREADS_ARG \
&& make install \
&& cd .. \
&& rm -r cmake-${CMAKE_VERSION}
# Install specific Go version
ENV GO_TAR_NAME=go$GO_VERSION.linux-$TARGETARCH.tar.gz
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
wget -N --progress=bar:force -P $DOWNLOADS_CACHE_DIR https://golang.org/dl/$GO_TAR_NAME && \
tar -C /usr/local -xzf $DOWNLOADS_CACHE_DIR/$GO_TAR_NAME
ENV PATH=$PATH:/usr/local/go/bin
WORKDIR /root
RUN echo "source scl_source enable gcc-toolset-12" >> /root/.bashrc
# For the deployment of Java artifacts to the Maven repository
COPY <<-"EOF" /root/.m2/settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>${JenkinsHops.RepoID}</id>
<username>${JenkinsHops.User}</username>
<filePermissions>664</filePermissions>
<directoryPermissions>775</directoryPermissions>
<password>${JenkinsHops.Password}</password>
</server>
</servers>
</settings>
EOF
#
# RDRS2
#
RUN --mount=type=cache,target=/var/cache/yum,id=oracle8-yum \
yum install bzip2 bzip2-libs
# Install latest boost
ENV BOOST_VERSION=${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_PATCH}
ENV BOOST_V_UNDERSCORE=${BOOST_VERSION_MAJOR}_${BOOST_VERSION_MINOR}_${BOOST_VERSION_PATCH}
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
cd $DOWNLOADS_CACHE_DIR && \
rm -rf boost_* && \
wget https://archives.boost.io/release/$BOOST_VERSION/source/boost_$BOOST_V_UNDERSCORE.tar.bz2 && \
tar --bzip2 -xf boost_$BOOST_V_UNDERSCORE.tar.bz2 && \
source scl_source enable gcc-toolset-12 && \
cd boost_$BOOST_V_UNDERSCORE && \
./bootstrap.sh &&\
./b2 -j$THREADS_ARG && \
./b2 install && \
rm -rf boost_*
# Install avro
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
cd $DOWNLOADS_CACHE_DIR && \
rm -rf release-* avro-* && \
wget -N --progress=bar:force -P $DOWNLOADS_CACHE_DIR https://github.com/apache/avro/archive/refs/tags/release-$AVRO_VERSION.tar.gz && \
tar xf release-$AVRO_VERSION.tar.gz && \
cd avro-release-$AVRO_VERSION/lang/c++ && \
mkdir build && \
cd build && \
source scl_source enable gcc-toolset-12 && \
cmake -G "Unix Makefiles" .. && \
make -j$THREADS_ARG && \
make install && \
rm -rf release-* avro-*
# Install updated jsoncpp
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
wget -N --progress=bar:force -P $DOWNLOADS_CACHE_DIR \
https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/$JSONCPP_VERSION.tar.gz \
&& tar xf $DOWNLOADS_CACHE_DIR/$JSONCPP_VERSION.tar.gz -C . \
&& source scl_source enable gcc-toolset-12 \
&& ls -al \
&& cd jsoncpp-$JSONCPP_VERSION \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=ON -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_INCLUDEDIR=include/jsoncpp .. \
&& make -j$THREADS_ARG \
&& make install \
&& cd ../.. \
&& rm -rf jsoncpp-$JSONCPP_VERSION $JSONCPP_VERSION.tar.gz
# See https://stackoverflow.com/a/51264575/9068781 for conditional envs
FROM rondb-build-dependencies as build-all
ARG DEPLOY_TO_REPO
ENV DEPLOY_ARG=${DEPLOY_TO_REPO:+-d}
ARG RELEASE_TARBALL
ENV RELEASE_ARG=${RELEASE_TARBALL:+-r}
ARG RELEASE_FINAL_CLUSTERJ
ENV RELEASE_FINAL_CLUSTERJ_ARG=${RELEASE_FINAL_CLUSTERJ:+-f}
ARG IS_PUBLIC_RELEASE
ENV IS_PUBLIC_RELEASE_ARG=${IS_PUBLIC_RELEASE:+-p}
RUN mkdir rondb-src rondb-bin rondb-tarball
RUN --mount=type=bind,source=.,target=rondb-src,readonly=false \
--mount=type=cache,target=rondb-bin,id=oracle8-rondb2210-bin \
source scl_source enable gcc-toolset-12 \
&& rondb-src/build_scripts/release_scripts/build_all.sh \
-s rondb-src \
-b rondb-bin \
-o rondb-tarball \
-j $THREADS_ARG \
$DEPLOY_ARG $RELEASE_ARG \
$RELEASE_FINAL_CLUSTERJ_ARG \
$IS_PUBLIC_RELEASE_ARG
# run with --output <output-folder>
FROM scratch AS get-package-all
COPY --from=build-all /root/rondb-tarball .
##################################
# Intermediate Image for RDRS ####
##################################
FROM oraclelinux:8 AS rdrs-intermediate
ENV MYSQL_HOME=/srv/hops/mysql
ENV MYSQL_CONF=/srv/hops/mysql-cluster
RUN mkdir -p $MYSQL_HOME && \
mkdir -p $MYSQL_HOME/bin && \
mkdir -p $MYSQL_HOME/lib && \
mkdir -p $MYSQL_HOME/lib/private && \
mkdir -p $MYSQL_CONF && \
mkdir -p $MYSQL_CONF/log
WORKDIR /root
COPY --from=build-all /root/rondb-tarball .
RUN --mount=type=bind,source=.,target=rondb-src \
mkdir distro && \
tar xzf *.tar.gz -C distro --strip-components=1 && \
cp distro/bin/rdrs $MYSQL_HOME/bin && \
cp distro/lib/libndbclient.so.6.1.0 $MYSQL_HOME/lib/ && \
cp distro/lib/librdrclient.so $MYSQL_HOME/lib/ && \
cp distro/lib/private/libcrypto.so.3 $MYSQL_HOME/lib/private && \
cp distro/lib/private/libssl.so.3 $MYSQL_HOME/lib/private && \
cp rondb-src/storage/ndb/rest-server/rest-api-server/resources/config/config_for_docker_image.json $MYSQL_CONF/rdrs_config.json
##################################
# RDRS Image #
##################################
FROM oraclelinux:8-slim AS rdrs
COPY --from=rdrs-intermediate /srv /srv
# Add RonDB libs to system path
COPY <<-"EOF" /etc/ld.so.conf.d/rondb.conf
/srv/hops/mysql/lib
/srv/hops/mysql/lib/private
EOF
RUN ldconfig -v
# Also setting LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=/srv/hops/mysql/lib:/srv/hops/mysql/lib/private
CMD ["/srv/hops/mysql/bin/rdrs", "-config", "/srv/hops/mysql-cluster/rdrs_config.json"]