Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

92212 - fix mssql container start #90

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions README.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= Intershop Commerce Management - Docker Plugins
:latestRevision: 4.0.0
:latestRevision: 4.1.0
:toc:
:icons: font

Expand Down Expand Up @@ -347,6 +347,7 @@ The following properties are part of the <<PropertiesFile>>.
| `intershop.db.mssql.dbname` | the name of the actual DB to be created | String | Optional | `icmtestdb` +
| `intershop.db.mssql.recreatedb` | controls if the actual DB is recreated on container start | Boolean | Optional | `false` +
| `intershop.db.mssql.recreateuser` | controls if the DB-user is recreated on container start | Boolean | Optional | `false` +
| `intershop.db.mssql.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
| `intershop.jdbc.user` | the name of the actual DB user to be created | String | Optional | `intershop` +
| `intershop.jdbc.password` | the password of the actual DB user to be created | String | Optional | `intershop` +
|===
Expand All @@ -359,6 +360,7 @@ The following properties are part of the <<PropertiesFile>>.

| `intershop.db.oracle.listenerport` | Exposed listener port of the database. | Integer | Optional | `1521` +
| `intershop.db.oracle.port` | Exposed enterprise manager port of the oracle db. | Integer | Optional | `1521` +
| `intershop.db.oracle.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== WA [[WAConfiguration]]
Expand All @@ -377,6 +379,16 @@ The following properties are part of the <<PropertiesFile>>.
| `intershop.ws.readinessProbe.interval` | interval in seconds to be used to check if the WebAdapter is ready | Integer | Optional | `2` +
| `intershop.ws.readinessProbe.timeout` | max. number of seconds to wait for the WebAdapter to become ready | Integer | Optional | `30` +
| `webserver.use.http2` | enables/disables usage of HTTP2 | Boolean | Optional | `false` +
| `wa.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== WAA [[WAAConfiguration]]

[cols="10%,60%,10%,10%,10%", width="99%, options="header"]
|===
| Key | Description | Co-domain | Mandatory/Optional | Default value

| `waa.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== NGINX [[NGINXConfiguration]]
Expand All @@ -389,6 +401,7 @@ The following properties are part of the <<PropertiesFile>>.
| `nginx.cert.path` | the host path to look for TLS certificate and private key (if not defined the certificates will be mounted from the Webserver certificate path) | Path | Optional | <none> +
| `nginx.cert.filename` | name of the certificate file | String | Optional | `fullchain.pem` +
| `nginx.privatekey.filename` | name of the certificate private key file | String | Optional | `privkey.pem` +
| `nginx.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== Solr [[SolrConfiguration]]
Expand All @@ -399,6 +412,7 @@ The following properties are part of the <<PropertiesFile>>.

| `solr.clusterIndexPrefix` | prefix to be used for indexed inside Solr | String | Optional | <empty> +
| `solr.port` | the host port to be used for the Solr server primary port | Integer | Optional | `8983` +
| `solr.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== ZooKeeper [[ZKConfiguration]]
Expand All @@ -409,12 +423,32 @@ The following properties are part of the <<PropertiesFile>>.

| `zookeeper.port` | the host port to be used for the Zookeeper's primary port | Integer | Optional | `2181` +
| `zookeeper.metrics.port` | the host port to be used for the Zookeeper's metrics port | Integer | Optional | `7000` +
| `zookeper.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `false` +
|===

===== Mail [[MailConfiguration]]

There are no special configuration properties for the mail server.
The SMTP port is `25` and the web interface listened on 8025. Mails are stored in the build directory `mailoutput`.
[cols="10%,60%,10%,10%,10%", width="99%, options="header"]
|===
| Key | Description | Co-domain | Mandatory/Optional | Default value

| `mail.smtp.host.port` | the host port to be used for the SMTP port | Integer | Optional | `25` +
| `mail.admin.host.port` | the host port to be used for the MailHog administration/backoffice port | Integer | Optional | `8025` +
| `mail.readinessProbe.interval` | interval in seconds to be used to check if the mail server is ready | Integer | Optional | `2` +
| `mail.readinessProbe.timeout` | max. number of seconds to wait for the mail server to become ready | Integer | Optional | `30` +
| `mail.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `true` +
|===

Mails are stored in the build directory `mailoutput`.

===== Redis [[RedisConfiguration]]

[cols="10%,60%,10%,10%,10%", width="99%, options="header"]
|===
| Key | Description | Co-domain | Mandatory/Optional | Default value

| `redis.useHostUser` | controls if the host system's current user is used for the container start | Boolean | Optional | `true` +
|===

== Intershop Commerce Management Customization Docker Plugin
This plugin configures additional tasks of an Intershop Commerce Management customization project. It uses the same Gradle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ open class DevelopmentConfiguration
}
}

fun getBooleanProperty(property: String, defaultValue: Boolean): Boolean {
val strValue = configProperties.getProperty(property, defaultValue.toString())
return strValue.toBoolean()
}

fun getDurationProperty(property: String, defaultSeconds: Int): Duration {
return Duration.ofSeconds(getIntProperty (property, defaultSeconds).toLong())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ abstract class AbstractTaskPreparer(
protected abstract fun getExtensionName(): String
protected open fun getContainerExt(): String = getExtensionName().lowercase()
protected abstract fun getImage(): Provider<String>
protected fun useHostUser() : Boolean {
return dockerExtension.developmentConfig.getBooleanProperty(getUseHostUserConfigProperty(), useHostUserDefaultValue())
}
protected open fun useHostUserDefaultValue() : Boolean = false
protected abstract fun getUseHostUserConfigProperty() : String;

protected val dockerExtension = project.extensions.getByType<IntershopDockerExtension>()
protected val icmExtension = project.extensions.getByType<IntershopExtension>()
Expand Down Expand Up @@ -95,8 +100,12 @@ abstract class AbstractTaskPreparer(
task.containerName.set(getContainerName())

val os: OperatingSystem = DefaultNativePlatform.getCurrentOperatingSystem()
if(! os.isWindows) {
val uid = com.sun.security.auth.module.UnixSystem().uid
if(useHostUser() && !os.isWindows) {
val system = com.sun.security.auth.module.UnixSystem()
val uid = system.uid
val userName = system.username
val gid = system.gid
project.logger.info("Using user {}({}:{}) to start container {}", userName, uid, gid, getContainerName())
task.user.set(uid.toString())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ object Configuration {
const val DB_MSSQL_DBNAME = "intershop.db.mssql.dbname"
const val DB_MSSQL_DBNAME_VALUE = "icmtestdb"

const val DB_MSSQL_USE_HOST_USER = "intershop.db.mssql.useHostUser"

const val DB_ORACLE_LISTENERPORT = "intershop.db.oracle.listenerport"
const val DB_ORACLE_CONTAINER_LISTENERPORT = "intershop.db.container.oracle.listenerport"

Expand All @@ -51,6 +53,8 @@ object Configuration {
const val DB_ORACLE_PORT_VALUE = "5500"
const val DB_ORACLE_CONTAINER_PORT_VALUE = "5500"

const val DB_ORACLE_USE_HOST_USER = "intershop.db.oracle.useHostUser"

const val DB_TYPE = "intershop.databaseType"
const val DB_JDBC_URL = "intershop.jdbc.url"

Expand Down Expand Up @@ -111,24 +115,30 @@ object Configuration {
const val WS_READINESS_PROBE_TIMEOUT = "intershop.db.readinessProbe.timeout"
const val WS_READINESS_PROBE_TIMEOUT_VALUE = 30 // 30 secs

const val WA_USE_HOST_USER = "wa.useHostUser"
const val WAA_USE_HOST_USER = "waa.useHostUser"

const val AS_ADMIN_USER_NAME = "intershop.smc.admin.user.name"
const val AS_ADMIN_USER_NAME_VALUE = "admin"
const val AS_ADMIN_USER_PASSWORD = "intershop.smc.admin.user.password"
const val AS_READINESS_PROBE_INTERVAL = "intershop.as.readinessProbe.interval"
const val AS_READINESS_PROBE_INTERVAL_VALUE = 15 // 15 secs
const val AS_READINESS_PROBE_TIMEOUT = "intershop.as.readinessProbe.timeout"
const val AS_READINESS_PROBE_TIMEOUT_VALUE = 100 * 60 // 100 mins (full dbinit may be necessary)
const val AS_USE_HOST_USER = "intershop.as.useHostUser"

const val SOLR_CLOUD_HOSTLIST = "solr.zooKeeperHostList"
const val SOLR_CLOUD_INDEXPREFIX = "solr.clusterIndexPrefix"
const val SOLR_CLOUD_HOST_PORT = "solr.port"
const val SOLR_CLOUD_HOST_PORT_VALUE = 8983
const val SOLR_DATA_FOLDER_PATH = "solr.data.folder.path"
const val SOLR_USE_HOST_USER = "solr.useHostUser"

const val ZOOKEEPER_HOST_PORT = "zookeeper.port"
const val ZOOKEEPER_HOST_PORT_VALUE = 2181
const val ZOOKEEPER_METRICS_HOST_PORT = "zookeeper.metrics.port"
const val ZOOKEEPER_METRICS_HOST_PORT_VALUE = 7000
const val ZOOKEEPER_USE_HOST_USER = "zookeeper.useHostUser"

const val SSL_VERIFICATION = "ssl.verification"

Expand Down Expand Up @@ -160,6 +170,7 @@ object Configuration {
const val MAIL_READINESS_PROBE_INTERVAL_VALUE = 1 // 1 secs
const val MAIL_READINESS_PROBE_TIMEOUT = "mail.readinessProbe.timeout"
const val MAIL_READINESS_PROBE_TIMEOUT_VALUE = 15 // 15 secs
const val MAIL_USE_HOST_USER = "mail.useHostUser"

const val NGINX_HTTP_PORT = "nginx.http.port"
const val NGINX_HTTPS_PORT = "nginx.https.port"
Expand All @@ -172,6 +183,9 @@ object Configuration {
const val NGINX_CERT_FILENAME_VALUE = "fullchain.pem"
const val NGINX_PRIVATEKEY_FILENAME = "nginx.privatekey.filename"
const val NGINX_PRIVATEKEY_FILENAME_VALUE = "privkey.pem"
const val NGINX_USE_HOST_USER = "nginx.useHostUser"

const val REDIS_USE_HOST_USER = "redis.useHostUser"

const val INTERSHOP_ENVIRONMENT_PREFIX = "intershop.environment."
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ abstract class AbstractASTaskPreparer(
initAppTasks()
}

override fun getUseHostUserConfigProperty(): String = Configuration.AS_USE_HOST_USER

val prepareServer: TaskProvider<Task> by lazy {
project.tasks.named(TaskPreparer.TASK_PREPARESERVER)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class CustomizationPreparer(project: Project,

override fun getExtensionName(): String = "${customizationName}$extPrefix"
override fun getImage(): Provider<String> = imagePath
override fun getUseHostUserConfigProperty(): String = getExtensionName()+".useHostUser"

override fun useHostUserDefaultValue(): Boolean = false

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class TaskPreparer(project: Project,

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.mailsrv
override fun getUseHostUserConfigProperty(): String = Configuration.MAIL_USE_HOST_USER

init {
initBaseTasks()
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class TaskPreparer(project: Project,

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.mssqldb
override fun getUseHostUserConfigProperty(): String = Configuration.DB_MSSQL_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class TaskPreparer(
override fun getExtensionName(): String = extName

override fun getImage(): Provider<String> = dockerExtension.images.nginx
override fun getUseHostUserConfigProperty(): String = Configuration.NGINX_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TaskPreparer(project: Project,

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.oracledb
override fun getUseHostUserConfigProperty(): String = Configuration.DB_ORACLE_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.intershop.gradle.icm.docker.utils.redis
import com.intershop.gradle.icm.docker.tasks.PrepareNetwork
import com.intershop.gradle.icm.docker.tasks.StartExtraContainer
import com.intershop.gradle.icm.docker.utils.AbstractTaskPreparer
import com.intershop.gradle.icm.docker.utils.Configuration
import com.intershop.gradle.icm.docker.utils.PortMapping
import org.gradle.api.Project
import org.gradle.api.provider.Provider
Expand All @@ -36,6 +37,7 @@ class TaskPreparer(
override fun getExtensionName(): String = extName

override fun getImage(): Provider<String> = dockerExtension.images.redis
override fun getUseHostUserConfigProperty(): String = Configuration.REDIS_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SolrPreparer(

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.solr
override fun getUseHostUserConfigProperty(): String = Configuration.SOLR_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class ZKPreparer(

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.zookeeper
override fun getUseHostUserConfigProperty(): String = Configuration.ZOOKEEPER_USE_HOST_USER

init {
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class WAATaskPreparer(project: Project,

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.webadapteragent
override fun getUseHostUserConfigProperty(): String = Configuration.WAA_USE_HOST_USER

init{
initBaseTasks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.intershop.gradle.icm.docker.tasks.StartExtraContainer
import com.intershop.gradle.icm.docker.tasks.utils.ContainerEnvironment
import com.intershop.gradle.icm.docker.utils.AbstractTaskPreparer
import com.intershop.gradle.icm.docker.utils.Configuration
import com.intershop.gradle.icm.docker.utils.Configuration.WA_USE_HOST_USER
import com.intershop.gradle.icm.docker.utils.Configuration.WS_READINESS_PROBE_INTERVAL
import com.intershop.gradle.icm.docker.utils.Configuration.WS_READINESS_PROBE_INTERVAL_VALUE
import com.intershop.gradle.icm.docker.utils.Configuration.WS_READINESS_PROBE_TIMEOUT
Expand All @@ -43,6 +44,7 @@ class WATaskPreparer(

override fun getExtensionName(): String = extName
override fun getImage(): Provider<String> = dockerExtension.images.webadapter
override fun getUseHostUserConfigProperty(): String = WA_USE_HOST_USER

val httpContainerPort: Int

Expand Down
Loading