Skip to content

Commit 7e9ac25

Browse files
PSMDB-1690 add bazel, PSMDB-1721 fix for unittests
1 parent edd278f commit 7e9ac25

File tree

1 file changed

+129
-32
lines changed

1 file changed

+129
-32
lines changed

regression-tests/build_image/Dockerfile_gcc_from_scratch

Lines changed: 129 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
ARG OS=debian:12
22
FROM $OS AS toolchain_builder
33
ARG toolchain_version=v4
4+
ARG bazel_version=7.6.1
5+
ARG TARGETARCH
46
RUN set -ex; \
57
if [ -f "/usr/bin/yum" ] ; \
68
then \
7-
yum -y update && yum install -y --allowerasing diffutils wget curl file glibc-devel gmp-devel mpfr-devel libmpc-devel gcc gcc-c++ bzip2 bzip2-devel openssl-devel zlib-devel libffi-devel xz-devel make tzdata ; \
9+
yum -y update && yum install -y --allowerasing diffutils wget curl file glibc-devel gmp-devel mpfr-devel libmpc-devel gcc gcc-c++ bzip2 bzip2-devel openssl-devel zlib-devel libffi-devel xz-devel make tzdata; \
810
else \
911
apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install wget curl file libgmp-dev libmpfr-dev libmpc-dev gcc g++ bzip2 libbz2-dev libssl-dev zlib1g-dev libreadline-dev libffi-dev make tzdata ; \
1012
fi
@@ -37,25 +39,42 @@ RUN set -ex; \
3739
./configure --prefix=/opt/python --enable-optimizations; \
3840
make -j "$(nproc)"; \
3941
make install; \
40-
cd /opt/ && rm -rf /opt/src/python && rm -rf /opt/python.tgz
42+
cd /opt/ && rm -rf /opt/src/python && rm -rf /opt/python.tgz && \
43+
if [ "$TARGETARCH" = "amd64" ]; then \
44+
TARGETARCH="x86_64"; \
45+
fi; \
46+
if [ "$toolchain_version" = "v5" ]; then \
47+
mkdir -p /opt/bazel && \
48+
wget https://github.com/bazelbuild/bazel/releases/download/${bazel_version}/bazel-${bazel_version}-linux-${TARGETARCH} -O /opt/bazel/bazel && \
49+
chmod +x /opt/bazel/bazel ;\
50+
fi
4151

4252
ARG OS=debian:12
43-
FROM $OS AS base_image
44-
ARG branch=v8.0
45-
ARG psm_ver=8.0.3
46-
ARG psm_release=1
47-
ARG repo=https://github.com/percona/percona-server-mongodb.git
53+
FROM $OS AS toolchain
54+
COPY --from=toolchain_builder /opt /opt
55+
ENV PATH="/opt/python/bin:/opt/gcc/bin:/opt/bazel:${PATH}"
4856
RUN set -ex; \
4957
if [ -f "/usr/bin/yum" ] ; then \
5058
yum -y update && yum install -y --allowerasing diffutils wget git curl cmake lld binutils glibc-devel tzdata; \
5159
else \
5260
apt-get update && apt-get -y upgrade && DEBIAN_FRONTEND=noninteractive apt-get -y install wget curl git cmake binutils lld tzdata; \
53-
fi
54-
COPY --from=toolchain_builder /opt /opt
55-
ENV PATH="/opt/python/bin:/opt/gcc/bin:${PATH}"
56-
RUN pip3 install --upgrade pip && pip3 install virtualenv && python3 -m venv /opt/venv
57-
ENV VIRTUAL_ENV /opt/venv
61+
fi; \
62+
pip3 install --upgrade pip && pip3 install virtualenv && python3 -m venv /opt/venv
63+
ENV VIRTUAL_ENV=/opt/venv
5864
ENV PATH="/opt/venv/bin:${PATH}"
65+
ENV POETRY_VIRTUALENVS_CREATE=false
66+
ENV POETRY_INSTALLER_MAX_WORKERS=10
67+
ENV PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
68+
ENV GLIBC_TUNABLES=glibc.pthread.rseq=0
69+
ENV CC=/opt/gcc/bin/gcc
70+
ENV CXX=/opt/gcc/bin/g++
71+
ENV PYTHON_BIN_PATH=/opt/venv/bin/python
72+
73+
FROM toolchain AS base_image
74+
ARG branch=v8.0
75+
ARG psm_ver=8.0.13
76+
ARG psm_release=4
77+
ARG repo=https://github.com/percona/percona-server-mongodb.git
5978
RUN cd /opt && mkdir -p percona-server-mongodb && \
6079
git clone $repo percona-server-mongodb && \
6180
cd percona-server-mongodb/ && \
@@ -66,17 +85,13 @@ RUN cd /opt && mkdir -p percona-server-mongodb && \
6685
\"githash\": \"${REVISION_LONG}\"\n\
6786
}" > version.json && \
6887
echo "mongo_version: \"$psm_ver-$psm_release\"" > .resmoke_mongo_version.yml && \
69-
rm -rf /opt/percona-server-mongodb/.git && mkdir -p /data/db
88+
rm -rf /opt/percona-server-mongodb/.git && mkdir -p /data/db
7089
WORKDIR /opt/percona-server-mongodb
71-
ENV POETRY_VIRTUALENVS_CREATE=false
72-
ENV POETRY_INSTALLER_MAX_WORKERS=10
73-
ENV PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
74-
ENV GLIBC_TUNABLES=glibc.pthread.rseq=0
7590
RUN set -ex; \
7691
if [ -f "/usr/bin/yum" ] ; then \
77-
yum install -y cmake openssl-devel openldap-devel krb5-devel libcurl-devel cyrus-sasl-devel bzip2-devel zlib-devel lz4-devel xz-devel e2fsprogs-devel iproute; \
92+
yum install -y cmake openssl-devel openldap-devel krb5-devel libcurl-devel cyrus-sasl-devel bzip2-devel zlib-devel lz4-devel xz-devel e2fsprogs-devel iproute glibc-debuginfo; \
7893
else \
79-
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake libssl-dev libldap2-dev libkrb5-dev libcurl4-openssl-dev libsasl2-dev liblz4-dev libbz2-dev libsnappy-dev zlib1g-dev libzlcore-dev liblzma-dev e2fslibs-dev iproute2; \
94+
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake libssl-dev libldap2-dev libkrb5-dev libcurl4-openssl-dev libsasl2-dev liblz4-dev libbz2-dev libsnappy-dev zlib1g-dev libzlcore-dev liblzma-dev e2fslibs-dev iproute2 libc6-dbg; \
8095
fi
8196
RUN set -ex; \
8297
pip install --upgrade pip; \
@@ -94,46 +109,129 @@ RUN set -ex; \
94109
fi
95110
ENV CMAKE_C_FLAGS=" -Wno-error=uninitialized "
96111
ENV CMAKE_CXX_FLAGS=" -Wno-error=deprecated-declarations -Wno-error=uninitialized "
97-
ENV AWS_LIBS=/opt/aws
98112
ARG AWS_VERSION=1.9.379
99113
RUN cd /opt && git clone https://github.com/aws/aws-sdk-cpp.git && \
100114
mkdir -p /opt/aws && \
101115
cd aws-sdk-cpp && git checkout $AWS_VERSION && git submodule update --init --recursive && \
102116
mkdir build && cd build && \
103-
cmake .. -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="s3;transfer" -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX="$AWS_LIBS" -DAUTORUN_UNIT_TESTS=OFF && \
117+
cmake .. -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="s3;transfer" -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_INSTALL_PREFIX="/usr" -DAUTORUN_UNIT_TESTS=OFF && \
104118
make -j "$(nproc)" && make install && \
105119
cd /opt && rm -rf aws-sdk-cpp
106-
ENV E2FS_LIBS=/opt/e2fs
107120
ARG E2FS_VERSION=v1.47.2
108121
RUN cd /opt && git clone https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git && \
109122
mkdir -p /opt/e2fs && \
110123
cd e2fsprogs && git checkout $E2FS_VERSION && \
111124
mkdir build && cd build && \
112-
../configure --prefix=$E2FS_LIBS && \
125+
../configure --prefix=/usr && \
113126
make -j "$(nproc)" && make install-libs && \
114127
cd /opt && rm -rf e2fsprogs
115128
RUN /usr/bin/echo -e "\n\
116129
CC = \"/opt/gcc/bin/gcc\"\n\
117130
CXX = \"/opt/gcc/bin/g++\"\n\
118-
CPPPATH = \"/opt/aws/include /opt/e2fs/include\"\n\
119-
LIBPATH = \"/opt/aws/lib /opt/aws/lib64 /opt/e2fs/lib /opt/e2fs/lib64\"\n\
131+
CPPPATH = \"/usr/include\"\n\
132+
LIBPATH = \"/usr/lib /usr/lib64\"\n\
120133
" > gcc.vars
134+
ENV MONGO_VERSION=$psm_ver-$psm_release
135+
ADD https://raw.githubusercontent.com/Percona-QA/psmdb-testing/main/regression-tests/resmoke2junit.py .
121136

122137
FROM base_image AS psmdb_builder
123-
ARG psm_ver=8.0.3
124-
ARG pro=""
138+
ARG build_platform=bazel
139+
ARG pro=true
140+
ENV PATH="/root/.local/bin:${PATH}"
125141
RUN set -ex; \
126-
VER=$(echo $psm_ver | cut -d"." -f1) && \
142+
VER=$(echo $MONGO_VERSION | cut -d"." -f1) && \
127143
if [ $VER -ge 8 ]; then \
128144
SCONS_TARGETS="install-mongod install-mongos install-mongo install-dbtest build/install/bin/mongobridge build/install/bin/wt build/install/bin/mongotmock" ;\
129145
else \
130146
SCONS_TARGETS="install-mongod install-mongos install-mongo install-dbtest build/install/bin/mongobridge build/install/bin/wt" ;\
131147
fi; \
132-
buildscripts/scons.py --variables-files=gcc.vars -j"$(nproc)" --disable-warnings-as-errors \
133-
--ssl --opt=on $pro --use-sasl-client --wiredtiger --audit --inmemory --hotbackup ${SCONS_TARGETS}
148+
$ff = "" ;\
149+
if [ "$pro" = "true" ] && [ "build_platform" = "bazel"]; then \
150+
$ff = "--full_featured" ;\
151+
fi; \
152+
if [ "$pro" = "true" ] && [ "build_platform" = "scons"]; then \
153+
$ff = "--full-featured" ;\
154+
fi; \
155+
if [ "$build_platform" = "bazel" ]; then \
156+
buildscripts/install_bazel.py && \
157+
bazel build --config=psmdb_opt_release $ff install-dist-test install-dbtest --define=MONGO_VERSION=$MONGO_VERSION && \
158+
mkdir -p build/install/bin && cp -RL bazel-bin/install/bin/* build/install/bin/ ;\
159+
else \
160+
buildscripts/scons.py --variables-files=gcc.vars -j"$(nproc)" --disable-warnings-as-errors \
161+
--ssl --opt=on $ff --use-sasl-client --wiredtiger --audit --inmemory --hotbackup ${SCONS_TARGETS} ;\
162+
fi
134163
RUN find build/install/bin -type f | xargs strip --strip-debug || true
135164

136-
FROM base_image
165+
FROM base_image AS unittests
166+
ARG build_platform=bazel
167+
ARG pro=true
168+
RUN useradd -u 1001 -g 0 -m -c "Default Application User" mongodb && \
169+
chown -R mongodb /opt && chown -R mongodb /data/db && mkdir /work && chown -R mongodb /work
170+
USER mongodb
171+
ENV PATH="/home/mongodb/.local/bin:${PATH}"
172+
RUN set -ex; \
173+
$ff = "" ;\
174+
if [ "$pro" = "true" ] && [ "build_platform" = "bazel"]; then \
175+
$ff = "--full_featured" ;\
176+
fi; \
177+
if [ "$pro" = "true" ] && [ "build_platform" = "scons"]; then \
178+
$ff = "--full-featured" ;\
179+
fi; \
180+
if [ "$build_platform" = "bazel" ]; then \
181+
buildscripts/install_bazel.py && \
182+
bazel build --define=MONGO_VERSION=$MONGO_VERSION --config=psmdb_dev --include_autogenerated_targets=True $ff install-mongo_unittest ;\
183+
else \
184+
buildscripts/scons.py --variables-files=gcc.vars -j"$(nproc)" --disable-warnings-as-errors \
185+
--ssl --link-model=dynamic --linker=gold --dbg=off --opt=off $ff --use-sasl-client --wiredtiger --audit --inmemory --hotbackup install-unittests ;\
186+
fi
187+
188+
FROM base_image AS integrationtests
189+
ARG build_platform=bazel
190+
ARG pro=true
191+
RUN useradd -u 1001 -g 0 -m -c "Default Application User" mongodb && \
192+
chown -R mongodb /opt && chown -R mongodb /data/db && mkdir /work && chown -R mongodb /work
193+
USER mongodb
194+
ENV PATH="/home/mongodb/.local/bin:${PATH}"
195+
RUN set -ex; \
196+
$ff = "" ;\
197+
if [ "$pro" = "true" ] && [ "build_platform" = "bazel"]; then \
198+
$ff = "--full_featured" ;\
199+
fi; \
200+
if [ "$pro" = "true" ] && [ "build_platform" = "scons"]; then \
201+
$ff = "--full-featured" ;\
202+
fi; \
203+
if [ "$build_platform" = "bazel" ]; then \
204+
buildscripts/install_bazel.py && \
205+
bazel build --define=MONGO_VERSION=$MONGO_VERSION --config=psmdb_dev --include_autogenerated_targets=True $ff install-mongo_integration_test ;\
206+
else \
207+
buildscripts/scons.py --variables-files=gcc.vars -j"$(nproc)" --disable-warnings-as-errors \
208+
--ssl --link-model=dynamic --linker=gold --dbg=off --opt=off $ff --use-sasl-client --wiredtiger --audit --inmemory --hotbackup install-integration-tests ;\
209+
fi
210+
211+
FROM base_image AS benchmarks
212+
ARG build_platform=bazel
213+
ARG pro=true
214+
RUN useradd -u 1001 -g 0 -m -c "Default Application User" mongodb && \
215+
chown -R mongodb /opt && chown -R mongodb /data/db && mkdir /work && chown -R mongodb /work
216+
USER mongodb
217+
ENV PATH="/home/mongodb/.local/bin:${PATH}"
218+
RUN set -ex; \
219+
$ff = "" ;\
220+
if [ "$pro" = "true" ] && [ "build_platform" = "bazel"]; then \
221+
$ff = "--full_featured" ;\
222+
fi; \
223+
if [ "$pro" = "true" ] && [ "build_platform" = "scons"]; then \
224+
$ff = "--full-featured" ;\
225+
fi; \
226+
if [ "$build_platform" = "bazel" ]; then \
227+
buildscripts/install_bazel.py && \
228+
bazel build --define=MONGO_VERSION=$MONGO_VERSION --config=psmdb_dev --include_autogenerated_targets=True $ff install-mongo_benchmark ;\
229+
else \
230+
buildscripts/scons.py --variables-files=gcc.vars -j"$(nproc)" --disable-warnings-as-errors \
231+
--ssl --link-model=dynamic --linker=gold --dbg=off --opt=off $ff --use-sasl-client --wiredtiger --audit --inmemory --hotbackup install-benchmarks ;\
232+
fi
233+
234+
FROM base_image AS jstests
137235
COPY --from=psmdb_builder /opt/percona-server-mongodb/build/install/bin/* /usr/bin/
138236
RUN find jstests -type f | xargs chmod 400 && \
139237
cp /usr/bin/dbtest . || true && \
@@ -144,6 +242,5 @@ ENV PYTHONPATH="/opt/percona-server-mongodb:/opt/percona-server-mongodb/src"
144242
ENV TZ=America/New_York
145243
ENV PORTABLE=1
146244
ENV USE_SSE=1
147-
ADD https://raw.githubusercontent.com/Percona-QA/psmdb-testing/main/regression-tests/resmoke2junit.py .
148245
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
149246
RUN useradd -u 1001 -r -g 0 -m -s /sbin/nologin -c "Default Application User" mongodb || true

0 commit comments

Comments
 (0)