diff --git a/.hadolint.yaml b/.hadolint.yaml index 90dc550567ba7..8f746efecc08b 100644 --- a/.hadolint.yaml +++ b/.hadolint.yaml @@ -20,3 +20,4 @@ ignored: - DL3008 - DL3005 - DL3013 + - SC1091 diff --git a/BREEZE.rst b/BREEZE.rst index 3fa459f218130..2352aded8f4de 100644 --- a/BREEZE.rst +++ b/BREEZE.rst @@ -1279,6 +1279,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -a, --install-airflow-version INSTALL_AIRFLOW_VERSION Uses different version of Airflow when building PROD image. @@ -1486,6 +1494,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -a, --install-airflow-version INSTALL_AIRFLOW_VERSION Uses different version of Airflow when building PROD image. @@ -1553,6 +1569,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -I, --production-image Use production image for entering the environment and builds (not for tests). @@ -1627,6 +1651,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -v, --verbose Show verbose information about executed docker, kind, kubectl, helm commands. Useful for debugging - when you run breeze with --verbose flags you will be able to see the commands @@ -1671,6 +1703,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + + #################################################################################################### @@ -1872,6 +1912,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -b, --backend BACKEND Backend to use for tests - it determines which database is used. One of: @@ -1948,6 +1996,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + -F, --force-build-images Forces building of the local docker images. The images are rebuilt automatically for the first time or when changes are detected in @@ -2354,6 +2410,14 @@ This is the current syntax for `./breeze <./breeze>`_: linux/amd64 + + -d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + + buster bullseye + **************************************************************************************************** Choose backend to run for Airflow diff --git a/Dockerfile b/Dockerfile index bb6df2fb50983..269059c9f7e0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -95,7 +95,6 @@ ARG DEV_APT_DEPS="\ lsb-release \ nodejs \ openssh-client \ - python-selinux \ sasl2-bin \ software-properties-common \ sqlite3 \ @@ -119,21 +118,20 @@ ENV DEV_APT_DEPS=${DEV_APT_DEPS} \ DEV_APT_COMMAND=${DEV_APT_COMMAND} \ ADDITIONAL_DEV_APT_COMMAND=${ADDITIONAL_DEV_APT_COMMAND} \ ADDITIONAL_DEV_APT_ENV=${ADDITIONAL_DEV_APT_ENV} +COPY scripts/docker/determine_debian_version_specific_variables.sh /scripts/docker/ -# Note missing man directories on debian-buster -# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 # Install basic and additional apt dependencies RUN apt-get update \ && apt-get install --no-install-recommends -yqq apt-utils >/dev/null 2>&1 \ - && apt-get install -y --no-install-recommends curl gnupg2 \ - && mkdir -pv /usr/share/man/man1 \ - && mkdir -pv /usr/share/man/man7 \ + && apt-get install -y --no-install-recommends curl gnupg2 lsb-release \ && export ${ADDITIONAL_DEV_APT_ENV?} \ + && source /scripts/docker/determine_debian_version_specific_variables.sh \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${DEV_APT_COMMAND}" \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${ADDITIONAL_DEV_APT_COMMAND}" \ && apt-get update \ && apt-get install -y --no-install-recommends \ ${DEV_APT_DEPS} \ + "${DISTRO_SELINUX}" \ ${ADDITIONAL_DEV_APT_DEPS} \ && apt-get autoremove -yqq --purge \ && apt-get clean \ @@ -375,7 +373,6 @@ ARG RUNTIME_APT_DEPS="\ gosu \ krb5-user \ ldap-utils \ - libffi6 \ libldap-2.4-2 \ libsasl2-2 \ libsasl2-modules \ @@ -407,20 +404,20 @@ ENV RUNTIME_APT_DEPS=${RUNTIME_APT_DEPS} \ GUNICORN_CMD_ARGS="--worker-tmp-dir /dev/shm" \ AIRFLOW_INSTALLATION_METHOD=${AIRFLOW_INSTALLATION_METHOD} -# Note missing man directories on debian-buster -# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 +COPY scripts/docker/determine_debian_version_specific_variables.sh /scripts/docker/ + # Install basic and additional apt dependencies RUN apt-get update \ && apt-get install --no-install-recommends -yqq apt-utils >/dev/null 2>&1 \ - && apt-get install -y --no-install-recommends curl gnupg2 \ - && mkdir -pv /usr/share/man/man1 \ - && mkdir -pv /usr/share/man/man7 \ + && apt-get install -y --no-install-recommends curl gnupg2 lsb-release \ && export ${ADDITIONAL_RUNTIME_APT_ENV?} \ + && source /scripts/docker/determine_debian_version_specific_variables.sh \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${RUNTIME_APT_COMMAND}" \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${ADDITIONAL_RUNTIME_APT_COMMAND}" \ && apt-get update \ && apt-get install -y --no-install-recommends \ ${RUNTIME_APT_DEPS} \ + "${DISTRO_LIBFFI}" \ ${ADDITIONAL_RUNTIME_APT_DEPS} \ && apt-get autoremove -yqq --purge \ && apt-get clean \ diff --git a/Dockerfile.ci b/Dockerfile.ci index c631a2c42c38e..005ee8c70daca 100644 --- a/Dockerfile.ci +++ b/Dockerfile.ci @@ -51,13 +51,16 @@ ENV DEV_APT_COMMAND=${DEV_APT_COMMAND} \ ADDITIONAL_DEV_APT_DEPS=${ADDITIONAL_DEV_APT_DEPS} \ ADDITIONAL_DEV_APT_COMMAND=${ADDITIONAL_DEV_APT_COMMAND} +COPY scripts/docker/determine_debian_version_specific_variables.sh /scripts/docker/ + # Install basic and additional apt dependencies RUN apt-get update \ && apt-get install --no-install-recommends -yqq apt-utils >/dev/null 2>&1 \ - && apt-get install -y --no-install-recommends curl gnupg2 \ + && apt-get install -y --no-install-recommends curl gnupg2 lsb-release \ && mkdir -pv /usr/share/man/man1 \ && mkdir -pv /usr/share/man/man7 \ && export ${ADDITIONAL_DEV_ENV_VARS?} \ + && source /scripts/docker/determine_debian_version_specific_variables.sh \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${DEV_APT_COMMAND}" \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${ADDITIONAL_DEV_APT_COMMAND}" \ && apt-get update \ @@ -79,7 +82,7 @@ RUN apt-get update \ libsasl2-dev \ libsasl2-modules \ libssl-dev \ - libenchant-dev \ + "${DISTRO_LIBENCHANT}" \ locales \ netcat \ nodejs \ @@ -112,7 +115,6 @@ RUN bash /scripts/docker/install_mysql.sh prod \ && chmod 0440 /etc/sudoers.d/airflow ARG RUNTIME_APT_DEPS="\ - libgcc-8-dev \ apt-transport-https \ bash-completion \ ca-certificates \ @@ -160,16 +162,14 @@ ENV RUNTIME_APT_DEP=${RUNTIME_APT_DEPS} \ AIRFLOW_HOME=${AIRFLOW_HOME} \ AIRFLOW_SOURCES=${AIRFLOW_SOURCES} -# Note missing man directories on debian-buster -# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 -RUN mkdir -pv /usr/share/man/man1 \ - && mkdir -pv /usr/share/man/man7 \ - && export ${ADDITIONAL_DEV_APT_ENV?} \ +RUN export ${ADDITIONAL_DEV_APT_ENV?} \ && export ${ADDITIONAL_RUNTIME_APT_ENV?} \ + && source /scripts/docker/determine_debian_version_specific_variables.sh \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${RUNTIME_APT_COMMAND}" \ && bash -o pipefail -o errexit -o nounset -o nolog -c "${ADDITIONAL_RUNTIME_APT_COMMAND}" \ && apt-get update \ && apt-get install --no-install-recommends -y \ + "${DISTRO_LIBGCC}" \ ${RUNTIME_APT_DEPS} \ ${ADDITIONAL_RUNTIME_APT_DEPS} \ && apt-get autoremove -yqq --purge \ diff --git a/INSTALL b/INSTALL index 208e6cd762731..4354d5e33f558 100644 --- a/INSTALL +++ b/INSTALL @@ -5,7 +5,7 @@ This is a generic installation method that requires a number of dependencies to Depending on your system you might need different prerequisites, but the following systems/prerequisites are known to work: -Linux (Debian Buster and Linux Mint Tricia): +Linux (Debian Bullseye and Linux Mint Debbie): sudo apt install build-essential python3-dev libsqlite3-dev openssl \ sqlite default-libmysqlclient-dev libmysqlclient-dev postgresql diff --git a/breeze b/breeze index 64a2daa0b9b05..48bae1eb1fc7c 100755 --- a/breeze +++ b/breeze @@ -515,6 +515,7 @@ EOF fi cat </dev/null || echo "unknown") @@ -816,6 +824,12 @@ function breeze::parse_arguments() { echo shift 2 ;; + -d | --debian-version) + export DEBIAN_VERSION="${2}" + echo "Debian version: ${DEBIAN_VERSION}" + echo + shift 2 + ;; -b | --backend) export BACKEND="${2}" echo "Backend: ${BACKEND}" @@ -940,7 +954,7 @@ function breeze::parse_arguments() { echo shift 2 ;; - -d | --db-reset) + --db-reset) echo "Resetting the DB!" echo export DB_RESET="true" @@ -1544,6 +1558,10 @@ function breeze::prepare_formatted_versions() { fold -w "${indented_screen_width}" -s | sed "s/^/${list_prefix}/") readonly FORMATTED_PYTHON_MAJOR_MINOR_VERSIONS + FORMATTED_DEBIAN_VERSIONS=$(echo "${_breeze_allowed_debian_versions=""}" | tr '\n' ' ' | + fold -w "${indented_screen_width}" -s | sed "s/^/${list_prefix}/") + readonly FORMATTED_DEBIAN_VERSIONS + FORMATTED_BACKENDS=$(echo "${_breeze_allowed_backends=""}" | tr '\n' ' ' | fold -w "${indented_screen_width}" -s | sed "s/^/${list_prefix}/") readonly FORMATTED_BACKENDS @@ -2260,6 +2278,14 @@ ${FORMATTED_PYTHON_MAJOR_MINOR_VERSIONS} ${FORMATTED_PLATFORMS} + +-d, --debian DEBIAN_VERSION + Debian version used for the image. This is always name of the debian distribution version. + + One of: + +${FORMATTED_DEBIAN_VERSIONS} + " } diff --git a/breeze-complete b/breeze-complete index 203a3131ff76c..2733e63661e53 100644 --- a/breeze-complete +++ b/breeze-complete @@ -23,6 +23,7 @@ # Those cannot be made read-only as the breeze-complete must be re-sourceable _breeze_allowed_python_major_minor_versions="3.7 3.8 3.9" +_breeze_allowed_debian_versions="buster bullseye" _breeze_allowed_backends="sqlite mysql postgres mssql" _breeze_allowed_integrations="cassandra kerberos mongo openldap pinot rabbitmq redis statsd trino all" _breeze_allowed_generate_constraints_modes="source-providers pypi-providers no-providers" @@ -43,6 +44,7 @@ _breeze_allowed_platforms="linux/amd64" # shellcheck disable=SC2034 { # Default values for the commands & flags used + _breeze_default_debian_version=$(echo "${_breeze_allowed_debian_versions}" | awk '{print $1}') _breeze_default_backend=$(echo "${_breeze_allowed_backends}" | awk '{print $1}') _breeze_default_generate_providers_mode=$(echo "${_breeze_allowed_generate_constraints_modes}" | awk '{print $1}') _breeze_default_kubernetes_mode=$(echo "${_breeze_allowed_kubernetes_modes}" | awk '{print $1}') @@ -166,7 +168,7 @@ _breeze_default_github_repository="apache/airflow" _breeze_default_github_image_id="latest" _breeze_short_options=" -h p: b: i: +h p: d: b: i: K: V: l a: t: d: v y n q f @@ -177,7 +179,7 @@ S: N: " _breeze_long_options=" -help python: backend: integration: platform: +help python: debian-version: backend: integration: platform: kubernetes-mode: kubernetes-version: helm-version: kind-version: skip-mounting-local-sources mount-all-local-sources install-airflow-version: install-airflow-reference: db-reset verbose assume-yes assume-no assume-quit forward-credentials init-script: @@ -256,6 +258,9 @@ function breeze_complete::get_known_values_breeze() { -p | --python) _breeze_known_values=${_breeze_allowed_python_major_minor_versions} ;; + -d | --debian-version) + _breeze_known_values=${_breeze_allowed_debian_versions} + ;; -b | --backend) _breeze_known_values=${_breeze_allowed_backends} ;; diff --git a/dev/provider_packages/prepare_provider_packages.py b/dev/provider_packages/prepare_provider_packages.py index ff9b9f4b9aa64..2b44dd9d6d18e 100755 --- a/dev/provider_packages/prepare_provider_packages.py +++ b/dev/provider_packages/prepare_provider_packages.py @@ -1039,7 +1039,7 @@ def make_sure_remote_apache_exists_and_fetch(git_update: bool, verbose: bool): if not git_update: return except subprocess.CalledProcessError as ex: - if ex.returncode == 128: + if ex.returncode == 128 or ex.returncode == 2: remote_add_command = [ "git", "remote", diff --git a/docs/docker-stack/build.rst b/docs/docker-stack/build.rst index e3e40c1abb3b6..131ccaf4fecaf 100644 --- a/docs/docker-stack/build.rst +++ b/docs/docker-stack/build.rst @@ -149,8 +149,6 @@ The following example adds ``test_dag.py`` to your image in the ``/opt/airflow/d :start-after: [START dag] :end-before: [END dag] - - Extending vs. customizing the image ----------------------------------- @@ -197,6 +195,7 @@ size of the Customized image. Airflow Summit 2020's `Production Docker Image `_ talk provides more details about the context, architecture and customization/extension methods for the Production Image. + Extending the image ------------------- @@ -414,6 +413,17 @@ contains specified version of dependencies to add with ``==`` version specifier, stable set of requirements, independent if someone releases a newer version. However you have to make sure to update those requirements and rebuild the images to account for latest security fixes. +Choosing Debian version when customizing the image +-------------------------------------------------- + +The reference Airflow image currently uses ``buster`` version of Debian (also known as Debian 10) as base +image, however when you want to build a custom image, you can also use ``bullseye`` version of base images. +Airflow supports both versions of Debian. You choose which version of Debian to use by choosing the +right version of python base image: + +* ``--build-arg PYTHON_BASE_IMAGE="python:3.7-slim-buster`` uses buster version of Debian (Debian 10) +* ``--build-arg PYTHON_BASE_IMAGE="python:3.7-slim-bullseye`` uses bullseye version of Debian (Debian 11) + Examples of image customizing ----------------------------- diff --git a/scripts/ci/docker-compose/_docker.env b/scripts/ci/docker-compose/_docker.env index 0f3a940eef378..341d85cef281f 100644 --- a/scripts/ci/docker-compose/_docker.env +++ b/scripts/ci/docker-compose/_docker.env @@ -26,6 +26,7 @@ CI_TARGET_REPO CI_TARGET_BRANCH COMMIT_SHA DB_RESET +DEBIAN_VERSION DEFAULT_BRANCH DEFAULT_CONSTRAINTS_BRANCH ENABLED_INTEGRATIONS diff --git a/scripts/ci/docker-compose/backend-mssql-bullseye.yml b/scripts/ci/docker-compose/backend-mssql-bullseye.yml new file mode 100644 index 0000000000000..4cf4d94570192 --- /dev/null +++ b/scripts/ci/docker-compose/backend-mssql-bullseye.yml @@ -0,0 +1,60 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +--- +version: "3.7" +services: + airflow: + environment: + - BACKEND=mssql + - AIRFLOW__CORE__SQL_ALCHEMY_CONN=mssql+pyodbc://sa:Airflow123@mssql:1433/airflow?driver=ODBC+Driver+18+for+SQL+Server&Encrypt=No + - AIRFLOW__CELERY__RESULT_BACKEND=db+mssql+pyodbc://sa:Airflow123@mssql:1433/airflow?driver=ODBC+Driver+18+for+SQL+Server&Encrypt=No + - AIRFLOW__CORE__EXECUTOR=LocalExecutor + depends_on: + mssql: + condition: service_healthy + mssqlsetup: + condition: service_completed_successfully + mssql: + image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION} + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=Airflow123 + healthcheck: + test: ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-S", "localhost", + "-U", "sa", "-P", "Airflow123", "-Q", "SELECT 1"] + interval: 10s + timeout: 10s + retries: 10 + start_period: 2m + restart: always + mssqlsetup: + image: mcr.microsoft.com/mssql/server:${MSSQL_VERSION} + depends_on: + mssql: + condition: service_healthy + entrypoint: + - bash + - -c + - > + for i in {1..10}; + do + /opt/mssql-tools/bin/sqlcmd -S mssql -U sa -P Airflow123 -i /mssql_create_airflow_db.sql && + exit 0; + sleep 1; + done + volumes: + - ./mssql_create_airflow_db.sql:/mssql_create_airflow_db.sql:ro diff --git a/scripts/ci/docker-compose/backend-mssql.yml b/scripts/ci/docker-compose/backend-mssql-buster.yml similarity index 100% rename from scripts/ci/docker-compose/backend-mssql.yml rename to scripts/ci/docker-compose/backend-mssql-buster.yml diff --git a/scripts/ci/docker-compose/base.yml b/scripts/ci/docker-compose/base.yml index 5125dd691ceb8..2cdc177df8a3b 100644 --- a/scripts/ci/docker-compose/base.yml +++ b/scripts/ci/docker-compose/base.yml @@ -40,6 +40,7 @@ services: - CI_TARGET_BRANCH=${CI_TARGET_BRANCH} - COMMIT_SHA=${COMMIT_SHA} - DB_RESET=${DB_RESET} + - DEBIAN_VERSION=${DEBIAN_VERSION} - DEFAULT_BRANCH=${DEFAULT_BRANCH} - DEFAULT_CONSTRAINTS_BRANCH=${DEFAULT_CONSTRAINTS_BRANCH} - ENABLED_INTEGRATIONS=${ENABLED_INTEGRATIONS} diff --git a/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh b/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh index dd5c27a9aefe4..b60d3d1f8c4ba 100755 --- a/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh +++ b/scripts/ci/testing/ci_run_single_airflow_test_in_docker.sh @@ -83,7 +83,11 @@ function run_airflow_testing_in_docker() { echo echo "Semaphore grabbed. Running tests for ${TEST_TYPE}" echo - local backend_docker_compose=("-f" "${SCRIPTS_CI_DIR}/docker-compose/backend-${BACKEND}.yml") + if [[ ${BACKEND} == "mssql" ]]; then + local backend_docker_compose=("-f" "${SCRIPTS_CI_DIR}/docker-compose/backend-${BACKEND}-${DEBIAN_VERSION}.yml") + else + local backend_docker_compose=("-f" "${SCRIPTS_CI_DIR}/docker-compose/backend-${BACKEND}.yml") + fi if [[ ${BACKEND} == "mssql" ]]; then local docker_filesystem docker_filesystem=$(stat "-f" "-c" "%T" /var/lib/docker 2>/dev/null || echo "unknown") diff --git a/scripts/docker/determine_debian_version_specific_variables.sh b/scripts/docker/determine_debian_version_specific_variables.sh new file mode 100644 index 0000000000000..735ee9d7a093c --- /dev/null +++ b/scripts/docker/determine_debian_version_specific_variables.sh @@ -0,0 +1,49 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# shellcheck disable=SC2148 +# Determines variables that are specific for different distro versions +function determine_debian_version_specific_variables() { + local color_red + color_red=$'\e[31m' + local color_reset + color_reset=$'\e[0m' + + local debian_version + debian_version=$(lsb_release -cs) + if [[ ${debian_version} == "buster" ]]; then + export DISTRO_LIBENCHANT="libenchant-dev" + export DISTRO_LIBGCC="libgcc-8-dev" + export DISTRO_SELINUX="python-selinux" + export DISTRO_LIBFFI="libffi6" + # Note missing man directories on debian-buster + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199 + mkdir -pv /usr/share/man/man1 + mkdir -pv /usr/share/man/man7 + elif [[ ${debian_version} == "bullseye" ]]; then + export DISTRO_LIBENCHANT="libenchant-2-2" + export DISTRO_LIBGCC="libgcc-10-dev" + export DISTRO_SELINUX="python3-selinux" + export DISTRO_LIBFFI="libffi7" + else + echo + echo "${color_red}Unknown distro version ${debian_version}${color_reset}" + echo + exit 1 + fi +} + +determine_debian_version_specific_variables diff --git a/scripts/docker/install_mssql.sh b/scripts/docker/install_mssql.sh index d80eff844cb42..024481d635695 100644 --- a/scripts/docker/install_mssql.sh +++ b/scripts/docker/install_mssql.sh @@ -21,24 +21,47 @@ set -euo pipefail COLOR_BLUE=$'\e[34m' readonly COLOR_BLUE +COLOR_YELLOW=$'\e[33m' +readonly COLOR_YELLOW COLOR_RESET=$'\e[0m' readonly COLOR_RESET function install_mssql_client() { + # Install MsSQL client from Microsoft repositories + if [[ ${INSTALL_MSSQL_CLIENT:="true"} != "true" ]]; then + echo + echo "${COLOR_BLUE}Skip installing mssql client${COLOR_RESET}" + echo + return + fi echo echo "${COLOR_BLUE}Installing mssql client${COLOR_RESET}" echo + local distro + local version + distro=$(lsb_release -is | tr '[:upper:]' '[:lower:]') + version_name=$(lsb_release -cs | tr '[:upper:]' '[:lower:]') + version=$(lsb_release -rs) + local driver + if [[ ${version_name} == "buster" ]]; then + driver=msodbcsql17 + elif [[ ${version_name} == "bullseye" ]]; then + driver=msodbcsql18 + else + echo + echo "${COLOR_YELLOW}Only Buster or Bullseye are supported. Skipping MSSQL installation${COLOR_RESET}" + echo + return + fi curl --silent https://packages.microsoft.com/keys/microsoft.asc | apt-key add - >/dev/null 2>&1 - curl --silent https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list + curl --silent "https://packages.microsoft.com/config/${distro}/${version}/prod.list" > \ + /etc/apt/sources.list.d/mssql-release.list apt-get update -yqq apt-get upgrade -yqq - ACCEPT_EULA=Y apt-get -yqq install -y --no-install-recommends msodbcsql17 mssql-tools + ACCEPT_EULA=Y apt-get -yqq install -y --no-install-recommends "${driver}" rm -rf /var/lib/apt/lists/* apt-get autoremove -yqq --purge apt-get clean && rm -rf /var/lib/apt/lists/* } -# Install MsSQL client from Microsoft repositories -if [[ ${INSTALL_MSSQL_CLIENT:="true"} == "true" ]]; then - install_mssql_client "${@}" -fi +install_mssql_client "${@}" diff --git a/scripts/docker/install_mysql.sh b/scripts/docker/install_mysql.sh index 137b25babff54..de2ecab0a05c2 100644 --- a/scripts/docker/install_mysql.sh +++ b/scripts/docker/install_mysql.sh @@ -29,10 +29,6 @@ readonly COLOR_RESET : "${INSTALL_MYSQL_CLIENT:?Should be true or false}" install_mysql_client() { - echo - echo "${COLOR_BLUE}Installing mysql client version ${MYSQL_VERSION}${COLOR_RESET}" - echo - if [[ "${1}" == "dev" ]]; then packages=("libmysqlclient-dev" "mysql-client") elif [[ "${1}" == "prod" ]]; then @@ -44,6 +40,10 @@ install_mysql_client() { exit 1 fi + echo + echo "${COLOR_BLUE}Installing mysql client version ${MYSQL_VERSION}: ${1}${COLOR_RESET}" + echo + local key="467B942D3A79BD29" readonly key