From c8becc92a7a13870fd0e76b04d0b976b4098fced Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:36:25 -0700 Subject: [PATCH 01/18] LPD-62912 Add configs for SQL Server --- .../liferay/docker/workspace/environments/Config.groovy | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy index ca1b0770..6ae06e73 100644 --- a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy +++ b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy @@ -191,6 +191,12 @@ class Config { this.dockerContainerDatabase = "${this.namespace}-database-postgres" } + if (this.services.contains("sqlserver")) { + this.useDatabase = true + this.useDatabaseSQLServer = true + this.dockerContainerDatabase = "${this.namespace}-database-sqlserver" + } + if (this.services.contains("webserver_http") && this.services.contains("webserver_https")) { throw new GradleException("Both HTTP and HTTPS are enabled for the webserver service. Only one protocol can be active at a time.") } @@ -300,6 +306,7 @@ class Config { public boolean useDatabaseMariaDB = false public boolean useDatabaseMySQL = false public boolean useDatabasePostgreSQL = false + public boolean useDatabaseSQLServer = false public boolean useLiferay = false public boolean useWebserverHttp = false public boolean useWebserverHttps = false From 3e328be2dc125c7aca7745271b56cd4672613c9b Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:37:52 -0700 Subject: [PATCH 02/18] LPD-62912 Include SQL Server JDBC jar in bundle --- build.gradle | 3 +++ .../src/main/groovy/docker-liferay-bundle.gradle | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/build.gradle b/build.gradle index 8e6791b1..84888b5d 100644 --- a/build.gradle +++ b/build.gradle @@ -130,12 +130,14 @@ buildDockerImage { dependsOn ":checkForLiferayLicense" dependsOn ":prepareDB2JDBCDriver" + dependsOn ":prepareSQLServerJDBCDriver" mustRunAfter ":importDatabaseDumps" } clean { dependsOn ":cleanPrepareDB2JDBCDriver" + dependsOn ":cleanPrepareSQLServerJDBCDriver" dependsOn ":cleanPrepareHotfixes" dependsOn ":cleanPrepareSelfSignedCert" dependsOn ":cleanPrepareWebserverConfig" @@ -145,6 +147,7 @@ clean { dockerDeploy { dependsOn ":prepareDB2JDBCDriver" + dependsOn ":prepareSQLServerJDBCDriver" dependsOn ":prepareHotfixes" dependsOn ":prepareYourKitAgent" } diff --git a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle index 81771d50..efd6a896 100644 --- a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle +++ b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle @@ -12,10 +12,12 @@ project.plugins.apply "docker-common" configurations { db2 + sqlserver } dependencies { db2 group: "com.ibm.db2.jcc", name: "db2jcc", version: "db2jcc4" + sqlserver group: "com.microsoft.sqlserver", name: "mssql-jdbc", version: "12.10.1.jre11" } Closure isValidLicenseFile = { @@ -202,6 +204,18 @@ tasks.register("prepareDB2JDBCDriver", Copy) { into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" } +tasks.register("prepareSQLServerJDBCDriver", Copy) { + onlyIf("using the Liferay service") { + config.useLiferay + } + onlyIf("using the SQL Server database") { + config.useDatabaseSQLServer + } + + from configurations.sqlserver + into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" +} + tasks.register("validateHotfixURLs") { onlyIf("using the Liferay service") { config.useLiferay From e76a263ef93acc6579806e076a0fce6ac35d4904 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:39:13 -0700 Subject: [PATCH 03/18] LPD-62912 Reuse DB2 database results for SQL Server --- buildSrc/src/main/groovy/docker-common.gradle | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/docker-common.gradle b/buildSrc/src/main/groovy/docker-common.gradle index 63a605c0..d432ddd2 100644 --- a/buildSrc/src/main/groovy/docker-common.gradle +++ b/buildSrc/src/main/groovy/docker-common.gradle @@ -50,7 +50,7 @@ ext { return toResultRows(results, /,/) } - if (config.useDatabaseDB2) { + if (config.useDatabaseDB2 || config.useDatabaseSQLServer) { List results = waitForCommand("${getDatabaseAccessCommand(schema)} \"${sql}\"").split("\n").minus("") results.removeLast() @@ -98,7 +98,12 @@ ext { return config.companyVirtualHosts } - config.companyVirtualHosts = executeSQLQuery("select companyId, hostname, webId from VirtualHost inner join Company using (companyId) where layoutSetId = 0", config.databaseName) + if (config.useDatabaseSQLServer) { + config.companyVirtualHosts = executeSQLQuery("select VirtualHost.companyId, hostname, webId from VirtualHost inner join Company on (VirtualHost.companyId = Company.companyId) where layoutSetId = 0", config.databaseName) + } + else { + config.companyVirtualHosts = executeSQLQuery("select companyId, hostname, webId from VirtualHost inner join Company using (companyId) where layoutSetId = 0", config.databaseName) + } return config.companyVirtualHosts } @@ -134,6 +139,10 @@ ext { "docker compose exec --user db2admin -it database /opt/ibm/db2/V11.5/bin/db2" ].join("\n") } + + if (config.useDatabaseSQLServer) { + return "docker compose exec -it database /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -C -P Liferay123 -d ${config.databaseName} -Q" + } } getCompanyDefaultWebId = { From 0f68412af504477643952580aa3733ab0f1388af Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:41:11 -0700 Subject: [PATCH 04/18] LPD-62912 Add recipe files for SQL Server --- compose-recipes/sqlserver/Dockerfile | 19 ++++++ .../sqlserver/clustering.sqlserver.yaml | 7 +++ compose-recipes/sqlserver/entrypoint.sh | 61 +++++++++++++++++++ compose-recipes/sqlserver/init.sql | 2 + .../sqlserver/liferay.sqlserver.yaml | 10 +++ compose-recipes/sqlserver/reinit.sql | 7 +++ .../sqlserver/service.sqlserver.yaml | 30 +++++++++ 7 files changed, 136 insertions(+) create mode 100644 compose-recipes/sqlserver/Dockerfile create mode 100644 compose-recipes/sqlserver/clustering.sqlserver.yaml create mode 100644 compose-recipes/sqlserver/entrypoint.sh create mode 100644 compose-recipes/sqlserver/init.sql create mode 100644 compose-recipes/sqlserver/liferay.sqlserver.yaml create mode 100644 compose-recipes/sqlserver/reinit.sql create mode 100644 compose-recipes/sqlserver/service.sqlserver.yaml diff --git a/compose-recipes/sqlserver/Dockerfile b/compose-recipes/sqlserver/Dockerfile new file mode 100644 index 00000000..f27c812b --- /dev/null +++ b/compose-recipes/sqlserver/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/mssql/server:2022-CU21-ubuntu-22.04 + +USER root + +RUN mkdir -p /var/opt/mssql/backups /var/opt/mssql/data +RUN chown -R mssql:mssql /var/opt/mssql/ +RUN touch /startup_log.txt +RUN chown mssql:mssql /startup_log.txt + +COPY entrypoint.sh /init/ +COPY init.sql /init/ +COPY reinit.sql /init + +RUN chown -R mssql:mssql /init && \ + chmod a+x /init/entrypoint.sh + +USER mssql + +ENTRYPOINT ["/bin/bash", "/init/entrypoint.sh"] \ No newline at end of file diff --git a/compose-recipes/sqlserver/clustering.sqlserver.yaml b/compose-recipes/sqlserver/clustering.sqlserver.yaml new file mode 100644 index 00000000..f9906d0d --- /dev/null +++ b/compose-recipes/sqlserver/clustering.sqlserver.yaml @@ -0,0 +1,7 @@ +services: + liferay-cluster-node: + environment: + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME=com.microsoft.sqlserver.jdbc.SQLServerDriver + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=Liferay123 + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL=jdbc:sqlserver://database:1433;databaseName=lportal;Encrypt=True;TrustServerCertificate=True + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=sa \ No newline at end of file diff --git a/compose-recipes/sqlserver/entrypoint.sh b/compose-recipes/sqlserver/entrypoint.sh new file mode 100644 index 00000000..989f1729 --- /dev/null +++ b/compose-recipes/sqlserver/entrypoint.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +_sqlcmd="/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${MSSQL_SA_PASSWORD}" + +_has_database_files() { + local database_name=${1} + + if [[ $(ls /var/opt/mssql/data | grep ${database_name}) ]]; then + echo true + fi +} + +_is_database_present() { + local database_name=${1} + + if [[ $(${_sqlcmd} -Q "select name from sys.databases" | grep "${database_name}") ]]; then + + echo true + fi +} + +create_database() { + local database_name=${1} + + if [[ $(_is_database_present ${database_name}) ]]; then + echo "Database ${database_name} is present; skipping database creation" + + return + fi + + if [[ $(_has_database_files ${database_name}) ]]; then + echo "Database files found; reattaching database ${database_name}..." + + sed -i "s,%DATABASE_NAME%,${database_name},g" /init/reinit.sql + + ${_sqlcmd} -i /init/reinit.sql + + return + fi + + echo "Could not find database ${database_name}; creating database..." + + sed -i "s,%DATABASE_NAME%,${database_name},g" /init/init.sql + + ${_sqlcmd} -i /init/init.sql + + return +} + +main() { + until ${_sqlcmd} -Q "SELECT 1"; do + sleep 1 + echo "[entrypoint] Waiting for SQL Server to be available..." + done + + create_database ${COMPOSER_DATABASE_NAME} +} + +main & /opt/mssql/bin/sqlservr + +wait \ No newline at end of file diff --git a/compose-recipes/sqlserver/init.sql b/compose-recipes/sqlserver/init.sql new file mode 100644 index 00000000..735ce181 --- /dev/null +++ b/compose-recipes/sqlserver/init.sql @@ -0,0 +1,2 @@ +CREATE DATABASE %DATABASE_NAME% +GO \ No newline at end of file diff --git a/compose-recipes/sqlserver/liferay.sqlserver.yaml b/compose-recipes/sqlserver/liferay.sqlserver.yaml new file mode 100644 index 00000000..ab7c401d --- /dev/null +++ b/compose-recipes/sqlserver/liferay.sqlserver.yaml @@ -0,0 +1,10 @@ +services: + liferay: + depends_on: + database: + condition: service_healthy + environment: + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME=com.microsoft.sqlserver.jdbc.SQLServerDriver + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_PASSWORD=Liferay123 + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_URL=jdbc:sqlserver://database:1433;databaseName=lportal;Encrypt=True;TrustServerCertificate=True + - LIFERAY_JDBC_PERIOD_DEFAULT_PERIOD_USERNAME=sa \ No newline at end of file diff --git a/compose-recipes/sqlserver/reinit.sql b/compose-recipes/sqlserver/reinit.sql new file mode 100644 index 00000000..70eec1cc --- /dev/null +++ b/compose-recipes/sqlserver/reinit.sql @@ -0,0 +1,7 @@ +USE master +GO +CREATE DATABASE %DATABASE_NAME% +ON (FILENAME = /var/opt/mssql/data/%DATABASE_NAME%.mdf), +(FILENAME = /var/opt/mssql/data/%DATABASE_NAME%.ldf) +FOR ATTACH +GO \ No newline at end of file diff --git a/compose-recipes/sqlserver/service.sqlserver.yaml b/compose-recipes/sqlserver/service.sqlserver.yaml new file mode 100644 index 00000000..00c8f694 --- /dev/null +++ b/compose-recipes/sqlserver/service.sqlserver.yaml @@ -0,0 +1,30 @@ +services: + data-helper: + volumes: + - sqlserver:/container-data/sqlserver + database: + build: ./compose-recipes/sqlserver + container_name: ${NAMESPACE}-database-sqlserver + deploy: + resources: + limits: + memory: 2G + reservations: + memory: 2G + environment: + - ACCEPT_EULA=Y + - COMPOSER_DATABASE_NAME=${DATABASE_NAME} + - MSSQL_SA_PASSWORD=Liferay123 + healthcheck: + interval: 5s + retries: 50 + start_period: 30s + test: /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P Liferay123 -Q "select name from sys.databases where name = ${DATABASE_NAME}" + timeout: 5s + ports: + - "1433:1433" + volumes: + - dumps:/var/opt/mssql/backups + - sqlserver:/var/opt/mssql/data +volumes: + sqlserver: \ No newline at end of file From 26d247e03ee314829fee766810bd190b3b4f47c4 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:42:03 -0700 Subject: [PATCH 05/18] LPD-62912 Optionally change ownership for SQL Server files in data-helper --- Dockerfile.helper | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile.helper b/Dockerfile.helper index 2dac7934..ef8fbdd1 100644 --- a/Dockerfile.helper +++ b/Dockerfile.helper @@ -1,7 +1,15 @@ -FROM busybox:latest +FROM alpine:latest ARG DATA_DIRECTORY=data USER 1000 -COPY --chown=1000:1000 ${DATA_DIRECTORY} /container-data \ No newline at end of file +COPY --chown=1000:1000 ${DATA_DIRECTORY} /container-data + +USER root + +RUN ([ -d /container-data/sqlserver ] && addgroup --gid 10001 mssql && adduser -S -s /usr/sbin/nologin -h /home/mssql --disabled-password -G mssql -u 10001 mssql) || echo + +RUN ([ -d /container-data/sqlserver ] && chown -R 10001:10001 /container-data/sqlserver) || echo + +USER 1000 \ No newline at end of file From ca759063e91eef7d52a3cd71dd4ce4dea9e4ea89 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:42:20 -0700 Subject: [PATCH 06/18] LPD-62912 Expose property for SQL Server --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 13253e84..49295b3b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,6 +46,7 @@ lr.docker.environment.service.enabled[mail]=false lr.docker.environment.service.enabled[mariadb]=false lr.docker.environment.service.enabled[mysql]=false lr.docker.environment.service.enabled[postgres]=false +lr.docker.environment.service.enabled[sqlserver]=false lr.docker.environment.service.enabled[webserver_http]=false lr.docker.environment.service.enabled[webserver_https]=false From f471fc7018ff2698a7e765298dffcdbbaec21c52 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 13:42:29 -0700 Subject: [PATCH 07/18] LPD-62912 Update README --- README.markdown | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.markdown b/README.markdown index bb5b1d1e..5ff7d217 100644 --- a/README.markdown +++ b/README.markdown @@ -29,6 +29,8 @@ To shut down the environment, run `./gradlew stop`. - [Enable MySQL 8.4](#enable-mysql-84) - [Enable PostgreSQL 16.3](#enable-postgresql-163) +- [Enable DB2 11.5](#enable-db2-115) +- [Enable Microsoft SQL Server 2022](#enable-microsoft-sql-server-2022) - [Import a database dump](#import-a-database-dump) - [Enable database partitioning (MySQL and PostgreSQL only)](#enable-database-partitioning-mysql-and-postgresql-only) - [Configure database port](#configure-database-port) @@ -228,6 +230,26 @@ Set the `lr.docker.environment.service.enabled[postgres]` property to `true` or lr.docker.environment.service.enabled[postgres]=true ``` +#### Enable DB2 11.5 + +Set the `lr.docker.environment.service.enabled[db2]` property to `true` or `1` in `gradle.properties`. + +`gradle.properties`: + +```properties +lr.docker.environment.service.enabled[db2]=true +``` + +#### Enable Microsoft SQL Server 2022 + +Set the `lr.docker.environment.service.enabled[sqlserver]` property to `true` or `1` in `gradle.properties`. + +`gradle.properties`: + +```properties +lr.docker.environment.service.enabled[sqlserver]=true +``` + #### Import a database dump Database dump files can be added to the `./dumps` directory at the root of the Workspace. They will automatically be copied into the database container. From 3c8018286e2cb6536238e739d26d45d24a7003fb Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 14:50:39 -0700 Subject: [PATCH 08/18] LPD-62912 Copy as root --- Dockerfile.helper | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile.helper b/Dockerfile.helper index ef8fbdd1..4dc4eb96 100644 --- a/Dockerfile.helper +++ b/Dockerfile.helper @@ -2,12 +2,8 @@ FROM alpine:latest ARG DATA_DIRECTORY=data -USER 1000 - COPY --chown=1000:1000 ${DATA_DIRECTORY} /container-data -USER root - RUN ([ -d /container-data/sqlserver ] && addgroup --gid 10001 mssql && adduser -S -s /usr/sbin/nologin -h /home/mssql --disabled-password -G mssql -u 10001 mssql) || echo RUN ([ -d /container-data/sqlserver ] && chown -R 10001:10001 /container-data/sqlserver) || echo From 0264e5e3c24446b4ad86fb2e282cafe23b8f9487 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Tue, 30 Sep 2025 15:49:04 -0700 Subject: [PATCH 09/18] LPD-62912 Using busybox is sufficient --- Dockerfile.helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.helper b/Dockerfile.helper index 4dc4eb96..81168d34 100644 --- a/Dockerfile.helper +++ b/Dockerfile.helper @@ -1,4 +1,4 @@ -FROM alpine:latest +FROM busybox:latest ARG DATA_DIRECTORY=data From 292c22548af1636c52b5439d00a92ca8bd8c84bc Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 14:49:35 -0700 Subject: [PATCH 10/18] LPD-62912 Convert to elif statements --- compose-recipes/sqlserver/entrypoint.sh | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/compose-recipes/sqlserver/entrypoint.sh b/compose-recipes/sqlserver/entrypoint.sh index 989f1729..2321ff0b 100644 --- a/compose-recipes/sqlserver/entrypoint.sh +++ b/compose-recipes/sqlserver/entrypoint.sh @@ -24,27 +24,19 @@ create_database() { if [[ $(_is_database_present ${database_name}) ]]; then echo "Database ${database_name} is present; skipping database creation" - - return - fi - - if [[ $(_has_database_files ${database_name}) ]]; then + elif [[ $(_has_database_files ${database_name}) ]]; then echo "Database files found; reattaching database ${database_name}..." sed -i "s,%DATABASE_NAME%,${database_name},g" /init/reinit.sql ${_sqlcmd} -i /init/reinit.sql + else + echo "Could not find database ${database_name}; creating database..." - return - fi - - echo "Could not find database ${database_name}; creating database..." - - sed -i "s,%DATABASE_NAME%,${database_name},g" /init/init.sql + sed -i "s,%DATABASE_NAME%,${database_name},g" /init/init.sql - ${_sqlcmd} -i /init/init.sql - - return + ${_sqlcmd} -i /init/init.sql + fi } main() { From b39cde7dcb288f8c12519b599c33e4444165ef83 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 14:57:21 -0700 Subject: [PATCH 11/18] LPD-62912 Add restore to entrypoint --- compose-recipes/sqlserver/Dockerfile | 1 + compose-recipes/sqlserver/entrypoint.sh | 16 ++++++++++++++++ compose-recipes/sqlserver/restore.sql | 5 +++++ 3 files changed, 22 insertions(+) create mode 100644 compose-recipes/sqlserver/restore.sql diff --git a/compose-recipes/sqlserver/Dockerfile b/compose-recipes/sqlserver/Dockerfile index f27c812b..4748d13d 100644 --- a/compose-recipes/sqlserver/Dockerfile +++ b/compose-recipes/sqlserver/Dockerfile @@ -10,6 +10,7 @@ RUN chown mssql:mssql /startup_log.txt COPY entrypoint.sh /init/ COPY init.sql /init/ COPY reinit.sql /init +COPY restore.sql /init RUN chown -R mssql:mssql /init && \ chmod a+x /init/entrypoint.sh diff --git a/compose-recipes/sqlserver/entrypoint.sh b/compose-recipes/sqlserver/entrypoint.sh index 2321ff0b..a3176a75 100644 --- a/compose-recipes/sqlserver/entrypoint.sh +++ b/compose-recipes/sqlserver/entrypoint.sh @@ -2,6 +2,12 @@ _sqlcmd="/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${MSSQL_SA_PASSWORD}" +_has_backup_file() { + if [[ $(find /var/opt/mssql/backups -type f -iname "*.bak") ]]; then + echo true + fi +} + _has_database_files() { local database_name=${1} @@ -24,6 +30,16 @@ create_database() { if [[ $(_is_database_present ${database_name}) ]]; then echo "Database ${database_name} is present; skipping database creation" + elif [[ $(_has_backup_file) ]]; then + echo "Database backup found; restoring database ${database_name}..." + + sed -i "s,%DATABASE_NAME%,${database_name},g" /init/restore.sql + + local backup_file=$(find /opt/var/mssql/backups -type f -iname "*.bak") + + sed -i "s,%BACKUP_FILE%,${backup_file},g" /init/restore.sql + + ${_sqlcmd} -i /init/restore.sql elif [[ $(_has_database_files ${database_name}) ]]; then echo "Database files found; reattaching database ${database_name}..." diff --git a/compose-recipes/sqlserver/restore.sql b/compose-recipes/sqlserver/restore.sql new file mode 100644 index 00000000..764c2ce9 --- /dev/null +++ b/compose-recipes/sqlserver/restore.sql @@ -0,0 +1,5 @@ +USE master +GO +RESTORE DATABASE %DATABASE_NAME% +FROM DISK = N'%BACKUP_FILE%' WITH FILE = 1, NOUNLOAD, REPLACE, STATS = 5 +GO \ No newline at end of file From 07f82a822a6f27130bee0570871a1980c065e1aa Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 15:00:12 -0700 Subject: [PATCH 12/18] LPD-62912 Update condition --- compose-recipes/sqlserver/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compose-recipes/sqlserver/entrypoint.sh b/compose-recipes/sqlserver/entrypoint.sh index a3176a75..ea1926f7 100644 --- a/compose-recipes/sqlserver/entrypoint.sh +++ b/compose-recipes/sqlserver/entrypoint.sh @@ -11,7 +11,7 @@ _has_backup_file() { _has_database_files() { local database_name=${1} - if [[ $(ls /var/opt/mssql/data | grep ${database_name}) ]]; then + if [[ $(find /var/opt/mssql/backups -type f -iname "${database_name}.*") ]]; then echo true fi } From bca79b165c7ccedf03f4a1b82fe7933499f90c73 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 15:32:31 -0700 Subject: [PATCH 13/18] LPD-62912 Add config for database type --- .../com/liferay/docker/workspace/environments/Config.groovy | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy index 6ae06e73..95f0df57 100644 --- a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy +++ b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy @@ -169,29 +169,34 @@ class Config { this.useClustering = this.useLiferay && this.clusterNodes > 0 if (this.services.contains("db2")) { + this.databaseType = "db2" this.useDatabase = true this.useDatabaseDB2 = true this.dockerContainerDatabase = "${this.namespace}-database-db2" } if (this.services.contains("mariadb")) { + this.databaseType = "db2" this.useDatabase = true this.useDatabaseMariaDB = true } if (this.services.contains("mysql")) { + this.databaseType = "mysql" this.useDatabase = true this.useDatabaseMySQL = true this.dockerContainerDatabase = "${this.namespace}-database-mysql" } if (this.services.contains("postgres")) { + this.databaseType = "postgres" this.useDatabase = true this.useDatabasePostgreSQL = true this.dockerContainerDatabase = "${this.namespace}-database-postgres" } if (this.services.contains("sqlserver")) { + this.databaseType = "sqlserver" this.useDatabase = true this.useDatabaseSQLServer = true this.dockerContainerDatabase = "${this.namespace}-database-sqlserver" @@ -283,6 +288,7 @@ class Config { public List> companyVirtualHosts = null public List composeFiles = new ArrayList() public String databaseName = "lportal" + public String databaseType = "" public boolean databasePartitioningEnabled = false public String dataDirectory = "data" public Map defaultCompanyVirtualHost = null From dc324f4211dbe34a0015a64b84b1ae9529e0fa46 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 15:33:00 -0700 Subject: [PATCH 14/18] LPD-62912 Consolidate jdbc driver tasks into one --- build.gradle | 9 +++------ .../main/groovy/docker-liferay-bundle.gradle | 20 ++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/build.gradle b/build.gradle index 84888b5d..305c6b8b 100644 --- a/build.gradle +++ b/build.gradle @@ -129,15 +129,13 @@ buildDockerImage { } dependsOn ":checkForLiferayLicense" - dependsOn ":prepareDB2JDBCDriver" - dependsOn ":prepareSQLServerJDBCDriver" + dependsOn ":prepareJDBCDriver" mustRunAfter ":importDatabaseDumps" } clean { - dependsOn ":cleanPrepareDB2JDBCDriver" - dependsOn ":cleanPrepareSQLServerJDBCDriver" + dependsOn ":cleanPrepareJDBCDriver" dependsOn ":cleanPrepareHotfixes" dependsOn ":cleanPrepareSelfSignedCert" dependsOn ":cleanPrepareWebserverConfig" @@ -146,8 +144,7 @@ clean { } dockerDeploy { - dependsOn ":prepareDB2JDBCDriver" - dependsOn ":prepareSQLServerJDBCDriver" + dependsOn ":prepareJDBCDriver" dependsOn ":prepareHotfixes" dependsOn ":prepareYourKitAgent" } diff --git a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle index efd6a896..d18e1c14 100644 --- a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle +++ b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle @@ -192,27 +192,15 @@ tasks.register("checkForLiferayLicense") { } } -tasks.register("prepareDB2JDBCDriver", Copy) { +tasks.register("prepareJDBCDriver", Copy) { onlyIf("using the Liferay service") { config.useLiferay } - onlyIf("using the DB2 database") { - config.useDatabaseDB2 + onlyIf("not using MySQL or PostgreSQL") { + config.useDatabaseDB2 || config.useDatabaseSQLServer } - from configurations.db2 - into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" -} - -tasks.register("prepareSQLServerJDBCDriver", Copy) { - onlyIf("using the Liferay service") { - config.useLiferay - } - onlyIf("using the SQL Server database") { - config.useDatabaseSQLServer - } - - from configurations.sqlserver + from configurations.(config.databaseType) into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" } From ffec61e46981743c6af917d2358b501625ae7711 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 15:33:26 -0700 Subject: [PATCH 15/18] LPD-62912 Add missing MariaDB config for consistency --- .../com/liferay/docker/workspace/environments/Config.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy index 95f0df57..eb76e687 100644 --- a/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy +++ b/buildSrc/src/main/groovy/com/liferay/docker/workspace/environments/Config.groovy @@ -179,6 +179,7 @@ class Config { this.databaseType = "db2" this.useDatabase = true this.useDatabaseMariaDB = true + this.dockerContainerDatabase = "${this.namespace}-database-mariadb" } if (this.services.contains("mysql")) { From 658f5eb7c3206686a6255db80064119242cea026 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 16:23:27 -0700 Subject: [PATCH 16/18] LPD-62912 Run copy task conditionally --- buildSrc/src/main/groovy/docker-liferay-bundle.gradle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle index d18e1c14..13f130bb 100644 --- a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle +++ b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle @@ -200,8 +200,10 @@ tasks.register("prepareJDBCDriver", Copy) { config.useDatabaseDB2 || config.useDatabaseSQLServer } - from configurations.(config.databaseType) - into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" + if (config.databaseType) { + from configurations.(config.databaseType) + into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" + } } tasks.register("validateHotfixURLs") { From 4e5f9ec5fc3e11c976397b70631a5ad2cdc36a35 Mon Sep 17 00:00:00 2001 From: Anthony Chu Date: Wed, 1 Oct 2025 16:23:47 -0700 Subject: [PATCH 17/18] LPD-62912 Add mssql jdbc jar to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9fa8570a..74f48b2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ **/*.iml **/*.so **/*db2jcc4.jar +**/*mssql-jdbc-12.10.1.jre11.jar **/*dxp-license-*.xml **/*hotfix*.zip **/.classpath From 5cea62eec8eb394e41dac6448e971da862d377a6 Mon Sep 17 00:00:00 2001 From: Drew Brokke Date: Thu, 2 Oct 2025 14:42:19 -0500 Subject: [PATCH 18/18] LPD-62912 uses the configuration itself to conditionally run the task --- .../src/main/groovy/docker-liferay-bundle.gradle | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle index 13f130bb..f8e7b4ec 100644 --- a/buildSrc/src/main/groovy/docker-liferay-bundle.gradle +++ b/buildSrc/src/main/groovy/docker-liferay-bundle.gradle @@ -192,18 +192,20 @@ tasks.register("checkForLiferayLicense") { } } +Configuration dbDriverConfiguration = configurations.findByName(config.databaseType) + tasks.register("prepareJDBCDriver", Copy) { onlyIf("using the Liferay service") { config.useLiferay } - onlyIf("not using MySQL or PostgreSQL") { - config.useDatabaseDB2 || config.useDatabaseSQLServer + onlyIf("there is a database driver to install") { + dbDriverConfiguration != null } - if (config.databaseType) { - from configurations.(config.databaseType) - into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" + from { + dbDriverConfiguration } + into "configs/common/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib" } tasks.register("validateHotfixURLs") {