Debian Codegraph @

mysqlx-connector-python/tests/docker/Dockerfile

raw
1 # Copyright (c) 2009, 2026, Oracle and/or its affiliates.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License, version 2.0, as
5 # published by the Free Software Foundation.
6 #
7 # This program is designed to work with certain software (including
8 # but not limited to OpenSSL) that is licensed under separate terms,
9 # as designated in a particular file or component or in included license
10 # documentation. The authors of MySQL hereby grant you an
11 # additional permission to link the program and your derivative works
12 # with the separately licensed software that they have either included with
13 # the program or referenced in the documentation.
14 #
15 # Without limiting anything contained in the foregoing, this file,
16 # which is part of MySQL Connector/Python, is also subject to the
17 # Universal FOSS Exception, version 1.0, a copy of which can be found at
18 # http://oss.oracle.com/licenses/universal-foss-exception.
19 #
20 # This program is distributed in the hope that it will be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 # See the GNU General Public License, version 2.0, for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write to the Free Software Foundation, Inc.,
27 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
29 # By default the container will use oracle linux 10 from OCR.
30 # The BASE_IMAGE environment variable can be used to pull
31 # any other Oracle Linux image from any other Docker registry.
32 ARG BASE_IMAGE=container-registry.oracle.com/os/oraclelinux:10-slim
33
34
35 FROM ${BASE_IMAGE} as pure_python
36 # In order to be able to run the tests within a private network,
37 # optional proxy configurations can be used.
38 ARG HTTP_PROXY
39 ARG HTTPS_PROXY
40 ARG NO_PROXY
41 ENV HTTP_PROXY=${HTTP_PROXY} HTTPS_PROXY=${HTTPS_PROXY} NO_PROXY=${NO_PROXY}
42 WORKDIR /connector-python
43 RUN microdnf install -y dnf \
44 && dnf install -y gcc-c++
45 # Install Python (including dev files), and create a virtual environment
46 RUN dnf -y install python3-pip python3-devel python3-setuptools
47 RUN python3 -m venv /pyenvs/venv
48 ENV PATH="/pyenvs/venv/bin:$PATH"
49 RUN pip install --upgrade setuptools
50 # This volume can be used to share, among other things,
51 # the Unix socket file with the container.
52 VOLUME [ "/shared" ]
53 # Providing a private PyPI repository is allowed
54 # [PIP_INDEX_URL]: https://wiki.onap.org/display/DW/Configure+and+customize+pip
55 ARG PYPI_REPOSITORY
56 ENV PIP_INDEX_URL=${PYPI_REPOSITORY:-https://pypi.org/simple}
57 # Install MySQL Connector/Python (python only)
58 COPY . .
59 RUN cd mysqlx-connector-python \
60 && pip install -r tests/requirements.txt \
61 && pip install .
62
63
64 FROM pure_python AS c_extension
65 RUN dnf install -y git cmake
66 RUN mkdir /tools /install
67 ENV DIR_CONNECTOR=/connector-python
68 ENV DIR_TOOLS=/tools
69 ENV DIR_INSTALL=/install
70 # Abseil: https://github.com/abseil/abseil-cpp
71 # Install Protobuf C++: https://github.com/protocolbuffers/protobuf
72 ENV ABSEIL_VERSION="20230802.1"
73 ENV PROTOBUF_VERSION="v5.29.4"
74 RUN cd $DIR_TOOLS \
75 && git clone --branch ${PROTOBUF_VERSION} https://github.com/protocolbuffers/protobuf.git \
76 && cd protobuf/third_party \
77 && git clone --branch ${ABSEIL_VERSION} https://github.com/abseil/abseil-cpp.git \
78 && cd .. \
79 && cmake . -DCMAKE_CXX_STANDARD=14 \
80 -Dprotobuf_BUILD_TESTS=OFF \
81 -Dprotobuf_ABSL_PROVIDER=module \
82 -DCMAKE_PREFIX_PATH=${DIR_TOOLS}/protobuf \
83 -DCMAKE_INSTALL_PREFIX=${DIR_INSTALL}/protobuf \
84 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
85 -Dprotobuf_MSVC_STATIC_RUNTIME=OFF \
86 && make -j$(nproc) \
87 && make install
88 # Build protobuf cext
89 RUN rm -rf ${DIR_TOOLS} \
90 && cd ${DIR_CONNECTOR} \
91 && cd mysqlx-connector-python \
92 && python setup.py install --with-protobuf-include-dir=${DIR_INSTALL}/protobuf/include \
93 --with-protobuf-lib-dir=${DIR_INSTALL}/protobuf/lib64 \
94 --with-protoc=${DIR_INSTALL}/protobuf/bin/protoc