
[id='application-configuration-using-environment-variables_{context}']
= Application configuration using environment variables

Use environment variables to configure your application in various deployments--especially in a containerized environment, such as Docker.

.Environment variables configuration
====
A property documented as `thorntail.undertow.servers.KEY.default-host` translates to the following environment variable (substituting the `KEY` segment with the `default` identifier):

[source,bash]
----
export THORNTAIL.UNDERTOW.SERVERS.DEFAULT.DEFAULT_DASH_HOST=<myhost>
----
====

Unlike other configuration options, properties defined as environment variables in Linux-based containers do not allow defining non-alphanumeric characters like _dot_ (.), _dash/hyphen_ (-) or any other characters not in the `[A-Za-z0-9_]` range.
Many configuration properties in {Thorntail} contain these characters, so you must follow these rules when defining the environment variables in the following environments:

.Linux-based container rules
* It is a naming convention that all environment properties are defined using uppercase letters.
For example, define the `serveraddress` property as `SERVERADDRESS`.
* All the _dot_ (.) characters must be replaced with _underscore_ (\_).
For example, define the `thorntail.bind.address=127.0.0.1` property as `THORNTAIL_BIND_ADDRESS=127.0.0.1`.
* All _dash/hyphen_ (-) characters must be replaced with the `_DASH_` string.
For example, define the `thorntail.data-sources.foo.url=<url>` property as `THORNTAIL_DATA_DASH_SOURCES_FOO_URL=<url>`.
* If the property name contains underscores, all _underscore_ (\_) characters must be replaced with the `_UNDERSCORE_` string.
For example, define the `thorntail.data_sources.foo.url=<url>` property as `THORNTAIL_DATA_UNDERSCORE_SOURCES_FOO_URL=<url>`.

.An example data source configuration
====
[cols="1,5"]
|===
| System property
| `-Dthorntail.datasources.data-sources.devwf.connection-url=
jdbc:postgresql://localhost:5432/sampledb`

| Env. variable
| `THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_DEVWF_CONNECTION_DASH_URL=
'jdbc:postgresql://localhost:5432/sampledb'`
|===

[cols="1,5"]
|===
| System property
| `-Dthorntail.datasources.data-sources.devwf.driver-name=postgresql`

| Env. variable
| `THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_DEVWF_DRIVER_DASH_NAME='postgresql'`
|===

[cols="1,5"]
|===
| System property
| `-Dthorntail.datasources.data-sources.devwf.jndiname=java:/jboss/datasources/devwf`

| Env. variable
| `THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_DEVWF_JNDI_DASH_NAME='java:/jboss/datasources/devwf'`
|===

[cols="1,5"]
|===
| System property
| `-Dthorntail.datasources.data-sources.devwf.user-name=postgres`

| Env. variable
| `THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_DEVWF_USER_DASH_NAME='postgres'`
|===

[cols="1,5"]
|===
| System property
| `-Dthorntail.datasources.data-sources.devwf.password=admin`

| Env. variable
| `THORNTAIL_DATASOURCES_DATA_DASH_SOURCES_DEVWF_PASSWORD='admin'`
|===
====

