This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1f26ae13cf Allow to install MariaDB client libraries instead of MySQL 
on x86_64 (#35070)
1f26ae13cf is described below

commit 1f26ae13cf974a0b2af6d8bc94c601d65e2bd98a
Author: Andrey Anshin <[email protected]>
AuthorDate: Tue Oct 24 12:54:09 2023 +0400

    Allow to install MariaDB client libraries instead of MySQL on x86_64 
(#35070)
    
    * Allow install MariaDB client libraries instead of MySQL on x86_64
    
    * MYSQL_CLIENT_TYPE -> INSTALL_MYSQL_CLIENT_TYPE
    
    * Add changelog information
    
    * Add notes that this feature is experimental
---
 Dockerfile                          | 16 +++++++++++++++-
 Dockerfile.ci                       | 17 +++++++++++++++--
 docs/docker-stack/build-arg-ref.rst |  5 +++++
 docs/docker-stack/changelog.rst     |  8 ++++++++
 scripts/docker/install_mysql.sh     | 17 ++++++++++++++---
 5 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index a33d901487..d7b2b7b282 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -195,6 +195,7 @@ COLOR_RESET=$'\e[0m'
 readonly COLOR_RESET
 
 : "${INSTALL_MYSQL_CLIENT:?Should be true or false}"
+: "${INSTALL_MYSQL_CLIENT_TYPE:-mysql}"
 
 export_key() {
     local key="${1}"
@@ -288,9 +289,18 @@ install_mariadb_client() {
 
 if [[ ${INSTALL_MYSQL_CLIENT:="true"} == "true" ]]; then
     if [[ $(uname -m) == "arm64" || $(uname -m) == "aarch64" ]]; then
+        INSTALL_MYSQL_CLIENT_TYPE="mariadb"
+    fi
+
+    if [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mysql" ]]; then
+        install_mysql_client "${@}"
+    elif [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mariadb" ]]; then
         install_mariadb_client "${@}"
     else
-        install_mysql_client "${@}"
+        echo
+        echo "${COLOR_RED}Specify either mysql or mariadb, got 
${INSTALL_MYSQL_CLIENT_TYPE}${COLOR_RESET}"
+        echo
+        exit 1
     fi
 fi
 EOF
@@ -1209,6 +1219,7 @@ COPY --from=scripts install_os_dependencies.sh 
/scripts/docker/
 RUN bash /scripts/docker/install_os_dependencies.sh dev
 
 ARG INSTALL_MYSQL_CLIENT="true"
+ARG INSTALL_MYSQL_CLIENT_TYPE="mysql"
 ARG INSTALL_MSSQL_CLIENT="true"
 ARG INSTALL_POSTGRES_CLIENT="true"
 ARG AIRFLOW_REPO=apache/airflow
@@ -1259,6 +1270,7 @@ ARG AIRFLOW_USER_HOME_DIR
 ARG AIRFLOW_UID
 
 ENV INSTALL_MYSQL_CLIENT=${INSTALL_MYSQL_CLIENT} \
+    INSTALL_MYSQL_CLIENT_TYPE=${INSTALL_MYSQL_CLIENT_TYPE} \
     INSTALL_MSSQL_CLIENT=${INSTALL_MSSQL_CLIENT} \
     INSTALL_POSTGRES_CLIENT=${INSTALL_POSTGRES_CLIENT}
 
@@ -1430,6 +1442,7 @@ ARG RUNTIME_APT_COMMAND="echo"
 ARG ADDITIONAL_RUNTIME_APT_COMMAND=""
 ARG ADDITIONAL_RUNTIME_APT_ENV=""
 ARG INSTALL_MYSQL_CLIENT="true"
+ARG INSTALL_MYSQL_CLIENT_TYPE="mysql"
 ARG INSTALL_MSSQL_CLIENT="true"
 ARG INSTALL_POSTGRES_CLIENT="true"
 
@@ -1438,6 +1451,7 @@ ENV RUNTIME_APT_DEPS=${RUNTIME_APT_DEPS} \
     RUNTIME_APT_COMMAND=${RUNTIME_APT_COMMAND} \
     ADDITIONAL_RUNTIME_APT_COMMAND=${ADDITIONAL_RUNTIME_APT_COMMAND} \
     INSTALL_MYSQL_CLIENT=${INSTALL_MYSQL_CLIENT} \
+    INSTALL_MYSQL_CLIENT_TYPE=${INSTALL_MYSQL_CLIENT_TYPE} \
     INSTALL_MSSQL_CLIENT=${INSTALL_MSSQL_CLIENT} \
     INSTALL_POSTGRES_CLIENT=${INSTALL_POSTGRES_CLIENT} \
     GUNICORN_CMD_ARGS="--worker-tmp-dir /dev/shm" \
diff --git a/Dockerfile.ci b/Dockerfile.ci
index 34068c7df3..08c4102747 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -155,6 +155,7 @@ COLOR_RESET=$'\e[0m'
 readonly COLOR_RESET
 
 : "${INSTALL_MYSQL_CLIENT:?Should be true or false}"
+: "${INSTALL_MYSQL_CLIENT_TYPE:-mysql}"
 
 export_key() {
     local key="${1}"
@@ -248,9 +249,18 @@ install_mariadb_client() {
 
 if [[ ${INSTALL_MYSQL_CLIENT:="true"} == "true" ]]; then
     if [[ $(uname -m) == "arm64" || $(uname -m) == "aarch64" ]]; then
+        INSTALL_MYSQL_CLIENT_TYPE="mariadb"
+    fi
+
+    if [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mysql" ]]; then
+        install_mysql_client "${@}"
+    elif [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mariadb" ]]; then
         install_mariadb_client "${@}"
     else
-        install_mysql_client "${@}"
+        echo
+        echo "${COLOR_RED}Specify either mysql or mariadb, got 
${INSTALL_MYSQL_CLIENT_TYPE}${COLOR_RESET}"
+        echo
+        exit 1
     fi
 fi
 EOF
@@ -1344,10 +1354,12 @@ COPY --from=scripts install_mysql.sh install_mssql.sh 
install_postgres.sh /scrip
 ARG HOME=/root
 ARG AIRFLOW_HOME=/root/airflow
 ARG AIRFLOW_SOURCES=/opt/airflow
+ARG INSTALL_MYSQL_CLIENT_TYPE="mysql"
 
 ENV HOME=${HOME} \
     AIRFLOW_HOME=${AIRFLOW_HOME} \
-    AIRFLOW_SOURCES=${AIRFLOW_SOURCES}
+    AIRFLOW_SOURCES=${AIRFLOW_SOURCES} \
+    INSTALL_MYSQL_CLIENT_TYPE=${INSTALL_MYSQL_CLIENT_TYPE}
 
 # We run scripts with bash here to make sure we can execute the scripts. 
Changing to +x might have an
 # unexpected result - the cache for Dockerfiles might get invalidated in case 
the host system
@@ -1435,6 +1447,7 @@ ENV AIRFLOW_REPO=${AIRFLOW_REPO}\
 # * install airflow in editable mode
 # * install always current version of airflow
     INSTALL_MYSQL_CLIENT="true" \
+    INSTALL_MYSQL_CLIENT_TYPE=${INSTALL_MYSQL_CLIENT_TYPE} \
     INSTALL_MSSQL_CLIENT="true" \
     INSTALL_POSTGRES_CLIENT="true" \
     AIRFLOW_INSTALLATION_METHOD="." \
diff --git a/docs/docker-stack/build-arg-ref.rst 
b/docs/docker-stack/build-arg-ref.rst
index a1767f0c91..39fe4bcb21 100644
--- a/docs/docker-stack/build-arg-ref.rst
+++ b/docs/docker-stack/build-arg-ref.rst
@@ -171,6 +171,11 @@ for examples of using those arguments.
 |                                          |                                   
       | The mysql extra is removed from extras   |
 |                                          |                                   
       | if the client is not installed.          |
 
+------------------------------------------+------------------------------------------+------------------------------------------+
+| ``INSTALL_MYSQL_CLIENT_TYPE``            | ``mysql``                         
       | (*Experimental*) Type of MySQL client    |
+|                                          |                                   
       | library. This can be ``mysql`` or        |
+|                                          |                                   
       | ``mariadb``. Regardless of the parameter |
+|                                          |                                   
       | will always be used ``mariadb`` on ARM.  |
++------------------------------------------+------------------------------------------+------------------------------------------+
 | ``INSTALL_MSSQL_CLIENT``                 | ``true``                          
       | Whether MsSQL client should be installed |
 
+------------------------------------------+------------------------------------------+------------------------------------------+
 | ``INSTALL_POSTGRES_CLIENT``              | ``true``                          
       | Whether Postgres client should be        |
diff --git a/docs/docker-stack/changelog.rst b/docs/docker-stack/changelog.rst
index a7f9653c29..304f9343c2 100644
--- a/docs/docker-stack/changelog.rst
+++ b/docs/docker-stack/changelog.rst
@@ -58,6 +58,14 @@ here so that users affected can find the reason for the 
changes.
 Airflow 2.7
 ~~~~~~~~~~~
 
+* 2.7.3
+
+  * Add experimental feature for select type of MySQL Client libraries during 
the build custom image via ``INSTALL_MYSQL_CLIENT_TYPE``
+    build arg. ``mysql`` for install MySQL client libraries from `Oracle APT 
repository <https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/>`_,
+    ``mariadb`` for install MariaDB client libraries from `MariaDB repository 
<https://mariadb.com/kb/en/mariadb-package-repository-setup-and-usage/#mariadb-repository>`_.
+    The selection of MySQL Client libraries only available on AMD64 (x86_64) 
for ARM docker image it will always install
+    MariaDB client.
+
 * 2.7.0
 
   * As of now, Python 3.7 is no longer supported by the Python community. 
Therefore, to use Airflow 2.7.0, you must ensure your Python version is
diff --git a/scripts/docker/install_mysql.sh b/scripts/docker/install_mysql.sh
index 82e5cc420f..3dbb2280c9 100644
--- a/scripts/docker/install_mysql.sh
+++ b/scripts/docker/install_mysql.sh
@@ -36,6 +36,7 @@ COLOR_RESET=$'\e[0m'
 readonly COLOR_RESET
 
 : "${INSTALL_MYSQL_CLIENT:?Should be true or false}"
+: "${INSTALL_MYSQL_CLIENT_TYPE:-mysql}"
 
 export_key() {
     local key="${1}"
@@ -128,13 +129,23 @@ install_mariadb_client() {
 }
 
 # Install MySQL client only if it is not disabled.
-# For amd64 (x86_64) install MySQL client from Oracle repositories.
-# For arm64 install MariaDB client from MariaDB repository, see:
+# INSTALL_MYSQL_CLIENT_TYPE=mysql : Install MySQL client from Oracle 
repository.
+# INSTALL_MYSQL_CLIENT_TYPE=mariadb : Install MariaDB client from MariaDB 
repository.
 # https://mariadb.com/kb/en/mariadb-clientserver-tcp-protocol/
+# For ARM64 INSTALL_MYSQL_CLIENT_TYPE ignored and always install MariaDB.
 if [[ ${INSTALL_MYSQL_CLIENT:="true"} == "true" ]]; then
     if [[ $(uname -m) == "arm64" || $(uname -m) == "aarch64" ]]; then
+        INSTALL_MYSQL_CLIENT_TYPE="mariadb"
+    fi
+
+    if [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mysql" ]]; then
+        install_mysql_client "${@}"
+    elif [[ "${INSTALL_MYSQL_CLIENT_TYPE}" == "mariadb" ]]; then
         install_mariadb_client "${@}"
     else
-        install_mysql_client "${@}"
+        echo
+        echo "${COLOR_RED}Specify either mysql or mariadb, got 
${INSTALL_MYSQL_CLIENT_TYPE}${COLOR_RESET}"
+        echo
+        exit 1
     fi
 fi

Reply via email to