-
Notifications
You must be signed in to change notification settings - Fork 45
/
Dockerfile.ubuntu22
252 lines (209 loc) · 9.22 KB
/
Dockerfile.ubuntu22
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
# syntax=docker/dockerfile:1.4
# This Dockerfile is not used for production builds. Ubuntu 22.04 comes with glibc 2.35,
# which is not supported by enough Linux distributions (Nov 2022). Glibc tends to be
# backwards compatible, but not forwards compatible. It is however recommended to use this
# Dockerfile for building on ARM for personal use.
FROM ubuntu:22.04 as rondb-build-dependencies
# Same as BUILDARCH
ARG TARGETARCH
ARG CMAKE_VERSION=3.25.1
ARG OPEN_SSL_VERSION=3.0.14
ARG GO_VERSION=1.22.9
ARG JSONCPP_VERSION=1.9.5
ARG AVRO_VERSION=1.12.0
ARG PROMETHEUS_CPP_VERSION=1.3.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}
RUN --mount=type=cache,target=/var/cache/apt,id=ubuntu22-apt \
--mount=type=cache,target=/var/lib/apt/lists,id=ubuntu22-apt-lists \
apt-get update && apt-get -y install wget pkg-config patchelf \
libncurses5-dev default-jdk libudev-dev bison flex autoconf pigz \
openssh-client maven libsasl2-dev libldap-dev libaio-dev \
git vim nano protobuf-compiler graphviz libboost-all-dev \
libcurl4-openssl-dev
# RonDB 22.10 requires gcc/g++ 10
# Ubuntu 22.04 comes with gcc/g++ 11.3 by default
# We will not remove the default installation, but change the default
# one using `update-alternatives`
# See https://askubuntu.com/a/26518/1646182 for reference
RUN --mount=type=cache,target=/var/cache/apt,id=ubuntu22-apt \
--mount=type=cache,target=/var/lib/apt/lists,id=ubuntu22-apt-lists \
apt-get update && apt-get install -y gcc-10 g++-10 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
# Creating a cache dir for downloads to avoid redownloading
ENV DOWNLOADS_CACHE_DIR=/tmp/downloads
RUN mkdir $DOWNLOADS_CACHE_DIR
# Commands are from https://linuxpip.org/install-openssl-linux/
ENV OPENSSL_ROOT=/usr/local/ssl
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
--mount=type=cache,target=/var/cache/apt,id=ubuntu22-apt \
--mount=type=cache,target=/var/lib/apt/lists,id=ubuntu22-apt-lists \
apt-get update -y \
&& apt-get install -y build-essential checkinstall zlib1g-dev \
&& 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 \
&& ./config --prefix=$OPENSSL_ROOT --openssldir=$OPENSSL_ROOT shared zlib \
&& make -j$THREADS_ARG \
&& make install \
&& echo "$OPENSSL_ROOT/lib" >> /etc/ld.so.conf.d/openssl-$OPEN_SSL_VERSION.conf \
&& ldconfig -v \
&& cd .. \
&& rm -r openssl-$OPEN_SSL_VERSION
# Could also run `make test`
# `make install` places shared libraries into $OPENSSL_ROOT
# For some reason installing OpenSSL changes gcc/g++ to 11
RUN update-alternatives --config gcc && update-alternatives --config g++
# Installing CMake
# CMake will look for $OPENSSL_ROOT_DIR
ENV OPENSSL_ROOT_DIR=$OPENSSL_ROOT
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
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
# For the deployment of Java artifacts to the Maven repository
# This is not needed by default, since we already deploy JAR files
# for x86 and they do not change across architectures.
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
#
# 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++ && \
./build.sh install && \
cd $DOWNLOADS_CACHE_DIR && \
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 . \
&& 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
# Run this *after* installing jsoncpp
RUN --mount=type=cache,target=/var/cache/apt,id=ubuntu22-apt \
--mount=type=cache,target=/var/lib/apt/lists,id=ubuntu22-apt-lists \
apt-get update -y \
&& apt-get install -y uuid-dev libudev-dev doxygen
# Install prometheus-cpp
RUN --mount=type=cache,target=$DOWNLOADS_CACHE_DIR \
cd $DOWNLOADS_CACHE_DIR \
&& rm -rf prometheus-cpp \
&& git clone https://github.com/jupp0r/prometheus-cpp \
&& cd prometheus-cpp \
&& git checkout tags/v${PROMETHEUS_CPP_VERSION} \
&& git submodule init \
&& git submodule update \
&& mkdir build \
&& cd build \
&& cmake .. -DBUILD_SHARED_LIBS=ON -DENABLE_PUSH=ON -DENABLE_COMPRESSION=OFF \
&& make -j$THREADS_ARG \
&& make install \
&& cd ../.. \
&& rm -rf prometheus-cpp
RUN mkdir rondb-src rondb-bin rondb-tarball
# See https://stackoverflow.com/a/51264575/9068781 for conditional envs
FROM rondb-build-dependencies as build-all
# Check deploy script what exactly will be deployed for ARM.
# JAR files should not be deployed; they do not change between
# architectures, so we only deploy them for x86
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 --mount=type=bind,source=.,target=rondb-src,readonly=false \
--mount=type=cache,target=rondb-bin,id=ubuntu22-rondb2210-bin \
--mount=type=cache,target=/root/.cache/go-build,id=ubuntu22-rondb2210-golang \
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 ubuntu:22.04 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 ubuntu:22.04 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"]