From 465166c35884d049e8956b0bcc32cce6e7e1b550 Mon Sep 17 00:00:00 2001 From: Angela Kuznetsova Date: Thu, 30 May 2024 09:38:57 +1200 Subject: [PATCH 1/7] Updated 8.2 and 8.3 images --- compose/build.yml | 24 ++++++++++++++++++++++++ compose/sync.yml | 24 ++++++++++++++++++++++++ php/php82/Dockerfile | 4 ++-- php/php83/Dockerfile | 4 ++-- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/compose/build.yml b/compose/build.yml index a191fff..5f69372 100644 --- a/compose/build.yml +++ b/compose/build.yml @@ -136,3 +136,27 @@ services: php-8.1-debug: build: ./php/php81-debug + php-8.2: + build: + context: ./php/php82 + args: + TIME_ZONE: ${TIME_ZONE} + + php-8.2-cron: + build: ./php/php82-cron + + php-8.2-debug: + build: ./php/php82-debug + + php-8.3: + build: + context: ./php/php83 + args: + TIME_ZONE: ${TIME_ZONE} + + php-8.3-cron: + build: ./php/php83-cron + + php-8.3-debug: + build: ./php/php83-debug + diff --git a/compose/sync.yml b/compose/sync.yml index 313e1c2..21cda90 100644 --- a/compose/sync.yml +++ b/compose/sync.yml @@ -136,6 +136,30 @@ services: volumes: - totara-www-sync:${REMOTE_SRC}:nocopy + php-8.2: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + + php-8.2-cron: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + + php-8.2-debug: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + + php-8.3: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + + php-8.3-cron: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + + php-8.3-debug: + volumes: + - totara-www-sync:${REMOTE_SRC}:nocopy + sync: image: alpine:latest container_name: totara_sync diff --git a/php/php82/Dockerfile b/php/php82/Dockerfile index c18311d..f40334a 100644 --- a/php/php82/Dockerfile +++ b/php/php82/Dockerfile @@ -89,9 +89,9 @@ RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \ # Workaround applied: https://github.com/microsoft/msphpsql/issues/1438#issuecomment-1444773949 RUN pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system \ - && pecl install sqlsrv-5.10.1 pdo_sqlsrv-5.10.1 || \ + && pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 || \ apt-get install -y --allow-downgrades odbcinst=2.3.7 odbcinst1debian2=2.3.7 unixodbc=2.3.7 unixodbc-dev=2.3.7 && \ - pecl install sqlsrv-5.10.1 pdo_sqlsrv-5.10.1 + pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 RUN docker-php-ext-enable sqlsrv.so && docker-php-ext-enable pdo_sqlsrv.so diff --git a/php/php83/Dockerfile b/php/php83/Dockerfile index da2df74..976dd02 100644 --- a/php/php83/Dockerfile +++ b/php/php83/Dockerfile @@ -89,9 +89,9 @@ RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \ # Workaround applied: https://github.com/microsoft/msphpsql/issues/1438#issuecomment-1444773949 RUN pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system \ - && pecl install sqlsrv-5.10.1 pdo_sqlsrv-5.10.1 || \ + && pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 || \ apt-get install -y --allow-downgrades odbcinst=2.3.7 odbcinst1debian2=2.3.7 unixodbc=2.3.7 unixodbc-dev=2.3.7 && \ - pecl install sqlsrv-5.10.1 pdo_sqlsrv-5.10.1 + pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 RUN docker-php-ext-enable sqlsrv.so && docker-php-ext-enable pdo_sqlsrv.so From 9fa2a4beb4bc351222b3291dd33b38680f22a0a8 Mon Sep 17 00:00:00 2001 From: kunleodusan Date: Fri, 12 Apr 2024 15:14:30 +1200 Subject: [PATCH 2/7] Set default collation for MySQL & Mariadb images to utf8mb4_unicode_ci --- mariadb/my.cnf | 4 ++++ mysql8/my.cnf | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mariadb/my.cnf b/mariadb/my.cnf index 6d8a52a..340f10b 100644 --- a/mariadb/my.cnf +++ b/mariadb/my.cnf @@ -10,3 +10,7 @@ tmp_table_size=134217728 max_heap_table_size=134217728 skip-name-resolve + +# Default server character-set and collation +character-set-server=utf8mb4 +collation-server=utf8mb4_unicode_ci diff --git a/mysql8/my.cnf b/mysql8/my.cnf index a08cf6b..237221a 100644 --- a/mysql8/my.cnf +++ b/mysql8/my.cnf @@ -1,2 +1,6 @@ [mysqld] -default-authentication-plugin=mysql_native_password \ No newline at end of file +default-authentication-plugin=mysql_native_password + +# Default server character-set and collation +character-set-server=utf8mb4 +collation-server=utf8mb4_unicode_ci \ No newline at end of file From cf689f3731cccf3693343b9aa02b83c89756dbba Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Thu, 27 Jun 2024 14:07:22 +1200 Subject: [PATCH 3/7] Adding MSSQL 2022 --- README.md | 2 +- compose/build.yml | 5 +++++ compose/mssql.yml | 20 ++++++++++++++++++++ mssql/2022/Dockerfile | 20 ++++++++++++++++++++ mssql/2022/custom/entrypoint.sh | 4 ++++ mssql/2022/custom/setup.sh | 13 +++++++++++++ mssql/2022/custom/setup.sql | 5 +++++ 7 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 mssql/2022/Dockerfile create mode 100644 mssql/2022/custom/entrypoint.sh create mode 100644 mssql/2022/custom/setup.sh create mode 100644 mssql/2022/custom/setup.sql diff --git a/README.md b/README.md index 8d2004f..6509b81 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Although this project started as a development environment for Totara Learn it c * [PostgreSQL](https://www.postgresql.org/) (9.3, 9.6, 10, 11, 12, 13, 14, 15, 16), * [MariaDB](https://mariadb.org/) (10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.11), * [MySQL](https://www.mysql.com/) (5.7, 8.0, 8.4), - * Microsoft SQL Server ([2017](https://www.microsoft.com/en-us/sql-server/sql-server-2017), [2019](https://www.microsoft.com/en-us/sql-server/sql-server-2019)) + * Microsoft SQL Server ([2017](https://www.microsoft.com/en-us/sql-server/sql-server-2017), [2019](https://www.microsoft.com/en-us/sql-server/sql-server-2019), [2022](https://www.microsoft.com/en-us/sql-server/sql-server-2022)) * [NodeJS](https://nodejs.org/) for building, developing and testing frontend code * A [PHPUnit](https://phpunit.de/) and [Behat](http://behat.org/en/latest/) setup to run tests (including [Selenium](https://www.seleniumhq.org/)) * A [mailcatcher](https://mailcatcher.me/) instance to view sent emails diff --git a/compose/build.yml b/compose/build.yml index 5f69372..6e544dd 100644 --- a/compose/build.yml +++ b/compose/build.yml @@ -16,6 +16,11 @@ services: context: ./mssql dockerfile: 2019/Dockerfile + mssql2022: + build: + context: ./mssql + dockerfile: 2022/Dockerfile + php-5.3: build: ./php/php53 diff --git a/compose/mssql.yml b/compose/mssql.yml index 368547d..553a742 100644 --- a/compose/mssql.yml +++ b/compose/mssql.yml @@ -38,6 +38,26 @@ services: networks: - totara + mssql2022: + image: totara/docker-dev-mssql2022 + # Mssql does not support multiple architectures + platform: linux/amd64 + container_name: totara_mssql2022 + ports: + - "1420:1433" + environment: + TZ: ${TIME_ZONE} + ACCEPT_EULA: Y + MSSQL_SA_PASSWORD: ${MSSQL_SA_PW} + MSSQL_PID: Developer + volumes: + - mssql2022-data:/var/opt/mssql + depends_on: + - nginx + networks: + - totara + volumes: mssql-data: mssql2019-data: + mssql2022-data: diff --git a/mssql/2022/Dockerfile b/mssql/2022/Dockerfile new file mode 100644 index 0000000..9497bc4 --- /dev/null +++ b/mssql/2022/Dockerfile @@ -0,0 +1,20 @@ +# mssql-agent-fts-ha-tools +# Maintainers: Microsoft Corporation (twright-msft on GitHub) +# GitRepo: https://github.com/Microsoft/mssql-docker + +FROM mcr.microsoft.com/mssql/server:2022-latest + +USER root + +RUN mkdir -p /usr/config +WORKDIR /usr/config + +COPY 2022/custom /usr/config + +RUN chmod +x /usr/config/*.sh && \ + chown mssql:mssql /usr/config/*.sh + +USER mssql + +# Run SQL Server process +ENTRYPOINT ["/usr/config/entrypoint.sh"] diff --git a/mssql/2022/custom/entrypoint.sh b/mssql/2022/custom/entrypoint.sh new file mode 100644 index 0000000..59343fa --- /dev/null +++ b/mssql/2022/custom/entrypoint.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# start SQL Server, start the script to create the DB and import the data, start the app +/opt/mssql/bin/sqlservr & /usr/config/setup.sh & tail -f /dev/null \ No newline at end of file diff --git a/mssql/2022/custom/setup.sh b/mssql/2022/custom/setup.sh new file mode 100644 index 0000000..a568e82 --- /dev/null +++ b/mssql/2022/custom/setup.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# The SQL server won't start by this time, so let's gently wait for it, if it won't start in 120 sec, let's fail anyway. +timeout=$(($(date +%s) + 120)) +until /opt/mssql-tools/bin/sqlcmd -H localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "select 'hello'" 2>/dev/null || [[ $(date +%s) -gt $timeout ]]; do + echo 'SQL server is not ready yet, sleeping for 2 seconds...' + sleep 2 +done + +echo "Running initial SQL statements" + +# run the setup script to run initial sql statements +/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "$MSSQL_SA_PASSWORD" -d master -i /usr/config/setup.sql diff --git a/mssql/2022/custom/setup.sql b/mssql/2022/custom/setup.sql new file mode 100644 index 0000000..b38b46b --- /dev/null +++ b/mssql/2022/custom/setup.sql @@ -0,0 +1,5 @@ +EXEC sp_configure 'show advanced options', 1; +RECONFIGURE; + +EXEC sp_configure 'clr strict security', 0; +RECONFIGURE; \ No newline at end of file From d8dd5fcf13507b635ddad27fdd88d7582e59c413 Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Tue, 2 Jul 2024 12:47:37 +1200 Subject: [PATCH 4/7] Rebasing off of Ubuntu directly to include mssql tools --- mssql/2022/Dockerfile | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/mssql/2022/Dockerfile b/mssql/2022/Dockerfile index 9497bc4..9a14988 100644 --- a/mssql/2022/Dockerfile +++ b/mssql/2022/Dockerfile @@ -2,19 +2,37 @@ # Maintainers: Microsoft Corporation (twright-msft on GitHub) # GitRepo: https://github.com/Microsoft/mssql-docker -FROM mcr.microsoft.com/mssql/server:2022-latest +FROM --platform=linux/amd64 ubuntu:22.04 -USER root +# Install Server FTS & HA +RUN apt-get update && \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get install -y \ + gnupg && \ + apt-get install -y \ + curl \ + locales \ + apt-transport-https && \ + curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.asc && \ + curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/mssql-server-2022.list | tee /etc/apt/sources.list.d/mssql-server-2022.list && \ + curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \ + export DEBIAN_FRONTEND=noninteractive && \ + apt-get update && \ + ACCEPT_EULA=Y apt-get install -y \ + mssql-server \ + mssql-server-ha \ + mssql-server-fts \ + mssql-tools18 \ + unixodbc-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists +# Copy the config across RUN mkdir -p /usr/config -WORKDIR /usr/config - COPY 2022/custom /usr/config +RUN chmod +x /usr/config/*.sh -RUN chmod +x /usr/config/*.sh && \ - chown mssql:mssql /usr/config/*.sh - -USER mssql +WORKDIR /usr/config # Run SQL Server process -ENTRYPOINT ["/usr/config/entrypoint.sh"] +CMD /bin/bash /usr/config/entrypoint.sh From 3cd71cd2a518f94b2908b3a473464e8787ee026b Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Tue, 2 Jul 2024 13:21:43 +1200 Subject: [PATCH 5/7] Support for local self-signed certificates --- bin/tdb | 2 +- mssql/2022/Dockerfile | 6 ++++-- mssql/2022/custom/entrypoint.sh | 7 +++++-- mssql/2022/custom/setup.sh | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/bin/tdb b/bin/tdb index 27d4d9f..b19b395 100755 --- a/bin/tdb +++ b/bin/tdb @@ -381,7 +381,7 @@ elif [ "$db_type" == 'mssql' ]; then if [[ "$php_container_name" == 'php-5.6' || "$php_container_name" == 'php-7.0' || "$php_container_name" == 'php-7.1' || "$php_container_name" == 'php-7.2' ]]; then sqlcmd="/opt/mssql-tools/bin/sqlcmd" else - sqlcmd="/opt/mssql-tools18/bin/sqlcmd -C" + sqlcmd="/opt/mssql-tools18/bin/sqlcmd -No -C" fi # Handles executing sql commands. diff --git a/mssql/2022/Dockerfile b/mssql/2022/Dockerfile index 9a14988..88ba9de 100644 --- a/mssql/2022/Dockerfile +++ b/mssql/2022/Dockerfile @@ -30,9 +30,11 @@ RUN apt-get update && \ # Copy the config across RUN mkdir -p /usr/config COPY 2022/custom /usr/config -RUN chmod +x /usr/config/*.sh + +RUN chmod +x /usr/config/entrypoint.sh +RUN chmod +x /usr/config/setup.sh WORKDIR /usr/config # Run SQL Server process -CMD /bin/bash /usr/config/entrypoint.sh +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/mssql/2022/custom/entrypoint.sh b/mssql/2022/custom/entrypoint.sh index 59343fa..5d9cac9 100644 --- a/mssql/2022/custom/entrypoint.sh +++ b/mssql/2022/custom/entrypoint.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash -# start SQL Server, start the script to create the DB and import the data, start the app -/opt/mssql/bin/sqlservr & /usr/config/setup.sh & tail -f /dev/null \ No newline at end of file +# Start the script to create the DB and import the data, start the app +/usr/config/setup.sh & + +# Start the server +/opt/mssql/bin/sqlservr \ No newline at end of file diff --git a/mssql/2022/custom/setup.sh b/mssql/2022/custom/setup.sh index a568e82..980465c 100644 --- a/mssql/2022/custom/setup.sh +++ b/mssql/2022/custom/setup.sh @@ -2,7 +2,7 @@ # The SQL server won't start by this time, so let's gently wait for it, if it won't start in 120 sec, let's fail anyway. timeout=$(($(date +%s) + 120)) -until /opt/mssql-tools/bin/sqlcmd -H localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "select 'hello'" 2>/dev/null || [[ $(date +%s) -gt $timeout ]]; do +until /opt/mssql-tools18/bin/sqlcmd -No -H localhost -U sa -P "$MSSQL_SA_PASSWORD" -Q "select 'hello'" || [[ $(date +%s) -gt $timeout ]]; do echo 'SQL server is not ready yet, sleeping for 2 seconds...' sleep 2 done @@ -10,4 +10,4 @@ done echo "Running initial SQL statements" # run the setup script to run initial sql statements -/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "$MSSQL_SA_PASSWORD" -d master -i /usr/config/setup.sql +/opt/mssql-tools18/bin/sqlcmd -No -S localhost -U SA -P "$MSSQL_SA_PASSWORD" -d master -i /usr/config/setup.sql From 08391f1b18825fa38cee62321408685d1ae8ba07 Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Tue, 2 Jul 2024 16:09:27 +1200 Subject: [PATCH 6/7] Adding MariaDB 11.4 --- README.md | 2 +- compose/mariadb.yml | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6509b81..db8e35e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Although this project started as a development environment for Totara Learn it c * [Apache](https://httpd.apache.org/) as a webserver * [PHP](http://php.net/) 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3 to test for different versions * [PostgreSQL](https://www.postgresql.org/) (9.3, 9.6, 10, 11, 12, 13, 14, 15, 16), - * [MariaDB](https://mariadb.org/) (10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.11), + * [MariaDB](https://mariadb.org/) (10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.11, 11.4), * [MySQL](https://www.mysql.com/) (5.7, 8.0, 8.4), * Microsoft SQL Server ([2017](https://www.microsoft.com/en-us/sql-server/sql-server-2017), [2019](https://www.microsoft.com/en-us/sql-server/sql-server-2019), [2022](https://www.microsoft.com/en-us/sql-server/sql-server-2022)) * [NodeJS](https://nodejs.org/) for building, developing and testing frontend code diff --git a/compose/mariadb.yml b/compose/mariadb.yml index ac1e5ec..24e1cef 100644 --- a/compose/mariadb.yml +++ b/compose/mariadb.yml @@ -1,5 +1,21 @@ services: + mariadb1104: + image: mariadb:11.4 + container_name: totara_mariadb1104 + ports: + - "3316:3306" + environment: + TZ: ${TIME_ZONE} + MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PW} + volumes: + - mariadb1104-data:/var/lib/mysql + - ./mariadb:/etc/mysql/conf.d + depends_on: + - nginx + networks: + - totara + mariadb1011: image: mariadb:10.11 container_name: totara_mariadb1011 @@ -130,6 +146,7 @@ services: volumes: mariadb-data: + mariadb1104-data: mariadb1011-data: mariadb108-data: mariadb107-data: From a0696eb1ddba6c645f9e32f542f2473bedca7068 Mon Sep 17 00:00:00 2001 From: Cody Finegan Date: Tue, 2 Jul 2024 16:57:52 +1200 Subject: [PATCH 7/7] Adding the new mariadb backup/restore and sql commands --- bin/tdb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/tdb b/bin/tdb index b19b395..f04744f 100755 --- a/bin/tdb +++ b/bin/tdb @@ -331,7 +331,14 @@ elif [ "$db_type" == 'mysqli' ]; then # MariaDB # ########################################## elif [ "$db_type" == 'mariadb' ]; then - db_sql_cmd="$db_command mysql -u\"$db_user\" -p\"$db_password\"" + if [[ "$db_host" == 'mariadb1104' ]]; then + db_maria_cmd="mariadb" + db_maria_backup_cmd="mariadb-dump" + else + db_maria_cmd="mysql" + db_maria_backup_cmd="mysqldump" + fi + db_sql_cmd="$db_command $db_maria_cmd -u\"$db_user\" -p\"$db_password\"" # Create mariadb database if [ "$action" == 'create' ]; then @@ -348,14 +355,14 @@ elif [ "$db_type" == 'mariadb' ]; then # Backup mariadb database elif [ "$action" == 'backup' ]; then - eval "$db_command mysqldump -u\"$db_user\" -p\"$db_password\" $db_name" > "$backup_file_local" || exit + eval "$db_command $db_maria_backup_cmd -u\"$db_user\" -p\"$db_password\" $db_name" > "$backup_file_local" || exit # Restore mariadb database elif [ "$action" == 'restore' ]; then eval "$db_sql_cmd -e \"DROP DATABASE IF EXISTS $db_name\"" eval "$db_sql_cmd -e \"CREATE DATABASE $db_name DEFAULT CHARACTER SET $character_set COLLATE $collation\"" docker cp "$backup_file_local" "$db_container":"$backup_file_remote" - $db_command sh -c "mysql -u\"$db_user\" -p\"$db_password\" $db_name < $backup_file_remote" >> /dev/null + $db_command sh -c "$db_maria_cmd -u\"$db_user\" -p\"$db_password\" $db_name < $backup_file_remote" >> /dev/null if [ "${PIPESTATUS[0]}" == '1' ]; then $db_command sh -c "rm $backup_file_remote" echo -e "\x1B[31mThere was an error while restoring $db_host database '$db_name' from file '$backup_file_local'\x1B[0m" @@ -365,7 +372,7 @@ elif [ "$db_type" == 'mariadb' ]; then # Start mariadb shell elif [ "$action" == 'shell' ]; then - docker exec -it "$db_container" sh -c "mysql -u\"$db_user\" -p\"$db_password\" -A $db_name" + docker exec -it "$db_container" sh -c "$db_maria_cmd -u\"$db_user\" -p\"$db_password\" -A $db_name" # Handle unimplemented action else