Skip to content

Commit 08bec4b

Browse files
committed
[#1672] Added support for database charset and collation to be taken from the env variables.
1 parent 2bb1c07 commit 08bec4b

21 files changed

Lines changed: 286 additions & 92 deletions

File tree

.vortex/docs/.utils/variables/extra/docker-compose.variables.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,36 @@ DRUPAL_PRIVATE_FILES="${DRUPAL_PRIVATE_FILES:-${DRUPAL_PUBLIC_FILES}/private}"
1414
DRUPAL_TEMPORARY_FILES="${DRUPAL_TEMPORARY_FILES:-${DRUPAL_PRIVATE_FILES}/tmp}"
1515

1616
# Local database host.
17+
#
18+
# Variable is not used in hosting environment.
1719
DATABASE_HOST=database
1820

1921
# Local database name.
22+
#
23+
# Variable is not used in hosting environment.
2024
DATABASE_NAME=drupal
2125

2226
# Local database user.
27+
#
28+
# Variable is not used in hosting environment.
2329
DATABASE_USERNAME=drupal
2430

2531
# Local database password.
32+
#
33+
# Variable is not used in hosting environment.
2634
DATABASE_PASSWORD=drupal
2735

2836
# Local database port.
37+
#
38+
# Variable is not used in hosting environment.
2939
DATABASE_PORT=3306
40+
41+
# Local database charset.
42+
#
43+
# Variable is not used in hosting environment.
44+
DATABASE_CHARSET=utf8mb4
45+
46+
# Local database collation.
47+
#
48+
# Variable is not used in hosting environment.
49+
DATABASE_COLLATION=utf8mb4_general_ci

.vortex/docs/content/workflows/variables.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ Default value: `UNDEFINED`
4444

4545
Defined in: `ENVIRONMENT`
4646

47+
### `DATABASE_CHARSET`
48+
49+
Local database charset.
50+
51+
Variable is not used in hosting environment.
52+
53+
Default value: `utf8mb4`
54+
55+
Defined in: `docker-compose.yml`
56+
57+
### `DATABASE_COLLATION`
58+
59+
Local database collation.
60+
61+
Variable is not used in hosting environment.
62+
63+
Default value: `utf8mb4_general_ci`
64+
65+
Defined in: `docker-compose.yml`
66+
4767
### `DATABASE_DATABASE`
4868

4969
Database name.
@@ -56,6 +76,8 @@ Defined in: `LAGOON ENVIRONMENT`
5676

5777
Local database host.
5878

79+
Variable is not used in hosting environment.
80+
5981
Default value: `database`
6082

6183
Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
@@ -64,6 +86,8 @@ Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
6486

6587
Local database name.
6688

89+
Variable is not used in hosting environment.
90+
6791
Default value: `drupal`
6892

6993
Defined in: `docker-compose.yml`
@@ -72,6 +96,8 @@ Defined in: `docker-compose.yml`
7296

7397
Local database password.
7498

99+
Variable is not used in hosting environment.
100+
75101
Default value: `drupal`
76102

77103
Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
@@ -80,6 +106,8 @@ Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
80106

81107
Local database port.
82108

109+
Variable is not used in hosting environment.
110+
83111
Default value: `3306`
84112

85113
Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
@@ -88,6 +116,8 @@ Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`
88116

89117
Local database user.
90118

119+
Variable is not used in hosting environment.
120+
91121
Default value: `drupal`
92122

93123
Defined in: `docker-compose.yml`, `scripts/vortex/info.sh`

.vortex/installer/tests/Fixtures/install/_baseline/docker-compose.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,28 @@ x-user: &default-user
3434
# Environment variables set in all containers during build and runtime.
3535
x-environment: &default-environment
3636
TZ: ${TZ:-Australia/Melbourne}
37+
# Pass-through 'CI' variable used to identify the CI environment.
38+
CI: ${CI:-}
39+
# Pass-through 'XDEBUG_ENABLE' to enable XDebug with "ahoy debug" or "XDEBUG_ENABLE=true docker compose up -d".
40+
XDEBUG_ENABLE: ${XDEBUG_ENABLE:-}
3741
# Local development URL.
3842
VORTEX_LOCALDEV_URL: &default-url ${COMPOSE_PROJECT_NAME:-example-site}.docker.amazee.io
3943
# Local development route used in Lagoon images and Pygmy to route requests.
4044
LAGOON_ROUTE: *default-url
41-
# Local database host (not used in production).
45+
# Local database host (variable is not used in hosting environment).
4246
DATABASE_HOST: database
43-
# Local database name (not used in production).
47+
# Local database name (variable is not used in hosting environment).
4448
DATABASE_NAME: drupal
45-
# Local database user (not used in production).
49+
# Local database user (variable is not used in hosting environment).
4650
DATABASE_USERNAME: drupal
47-
# Local database password (not used in production).
51+
# Local database password (variable is not used in hosting environment).
4852
DATABASE_PASSWORD: drupal
49-
# Local database port (not used in production).
53+
# Local database port (variable is not used in hosting environment).
5054
DATABASE_PORT: 3306
51-
# Pass-through 'XDEBUG_ENABLE' to enable XDebug with "ahoy debug" or "XDEBUG_ENABLE=true docker compose up -d".
52-
XDEBUG_ENABLE: ${XDEBUG_ENABLE:-}
53-
# Pass-through 'CI' variable used to identify the CI environment.
54-
CI: ${CI:-}
55+
# Local database charset (variable is not used in hosting environment).
56+
DATABASE_CHARSET: utf8mb4
57+
# Local database collation (variable is not used in hosting environment).
58+
DATABASE_COLLATION: utf8mb4_general_ci
5559
DRUPAL_THEME: ${DRUPAL_THEME:-}
5660
# Path to configuration files.
5761
DRUPAL_CONFIG_PATH: ${DRUPAL_CONFIG_PATH:-/app/config/default}

.vortex/installer/tests/Fixtures/install/_baseline/tests/phpunit/Drupal/DatabaseSettingsTest.php

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static function dataProviderDatabases(): array {
4141
'password' => 'drupal',
4242
'host' => 'localhost',
4343
'port' => '',
44+
'charset' => 'utf8mb4',
45+
'collation' => 'utf8mb4_general_ci',
4446
'driver' => 'mysql',
4547
'prefix' => '',
4648
],
@@ -50,20 +52,24 @@ public static function dataProviderDatabases(): array {
5052

5153
[
5254
[
53-
'DATABASE_NAME' => 'test_db_name',
54-
'DATABASE_USERNAME' => 'test_db_user',
55-
'DATABASE_PASSWORD' => 'test_db_pass',
56-
'DATABASE_HOST' => 'test_db_host',
57-
'DATABASE_PORT' => 'test_db_port',
55+
'DATABASE_NAME' => 'database_db_name',
56+
'DATABASE_USERNAME' => 'database_db_user',
57+
'DATABASE_PASSWORD' => 'database_db_pass',
58+
'DATABASE_HOST' => 'database_db_host',
59+
'DATABASE_PORT' => 'database_db_port',
60+
'DATABASE_CHARSET' => 'database_utf8',
61+
'DATABASE_COLLATION' => 'database_utf8_unicode_ci',
5862
],
5963
[
6064
'default' => [
6165
'default' => [
62-
'database' => 'test_db_name',
63-
'username' => 'test_db_user',
64-
'password' => 'test_db_pass',
65-
'host' => 'test_db_host',
66-
'port' => 'test_db_port',
66+
'database' => 'database_db_name',
67+
'username' => 'database_db_user',
68+
'password' => 'database_db_pass',
69+
'host' => 'database_db_host',
70+
'port' => 'database_db_port',
71+
'charset' => 'database_utf8',
72+
'collation' => 'database_utf8_unicode_ci',
6773
'driver' => 'mysql',
6874
'prefix' => '',
6975
],
@@ -73,20 +79,51 @@ public static function dataProviderDatabases(): array {
7379

7480
[
7581
[
76-
'DATABASE_DATABASE' => 'test_db_name',
77-
'DATABASE_USERNAME' => 'test_db_user',
78-
'DATABASE_PASSWORD' => 'test_db_pass',
79-
'DATABASE_HOST' => 'test_db_host',
80-
'DATABASE_PORT' => 'test_db_port',
82+
'MARIADB_DATABASE' => 'mariadb_db_name',
83+
'MARIADB_USERNAME' => 'mariadb_db_user',
84+
'MARIADB_PASSWORD' => 'mariadb_db_pass',
85+
'MARIADB_HOST' => 'mariadb_db_host',
86+
'MARIADB_PORT' => 'mariadb_db_port',
87+
'MARIADB_CHARSET' => 'mariadb_latin1',
88+
'MARIADB_COLLATION' => 'mariadb_latin1_swedish_ci',
8189
],
8290
[
8391
'default' => [
8492
'default' => [
85-
'database' => 'test_db_name',
86-
'username' => 'test_db_user',
87-
'password' => 'test_db_pass',
88-
'host' => 'test_db_host',
89-
'port' => 'test_db_port',
93+
'database' => 'mariadb_db_name',
94+
'username' => 'mariadb_db_user',
95+
'password' => 'mariadb_db_pass',
96+
'host' => 'mariadb_db_host',
97+
'port' => 'mariadb_db_port',
98+
'charset' => 'mariadb_latin1',
99+
'collation' => 'mariadb_latin1_swedish_ci',
100+
'driver' => 'mysql',
101+
'prefix' => '',
102+
],
103+
],
104+
],
105+
],
106+
107+
[
108+
[
109+
'DATABASE_DATABASE' => 'database_db_name',
110+
'DATABASE_USERNAME' => 'database_db_user',
111+
'DATABASE_PASSWORD' => 'database_db_pass',
112+
'DATABASE_HOST' => 'database_db_host',
113+
'DATABASE_PORT' => 'database_db_port',
114+
'MYSQL_CHARSET' => 'mysql_utf8mb3',
115+
'MYSQL_COLLATION' => 'mysql_utf8mb3_bin',
116+
],
117+
[
118+
'default' => [
119+
'default' => [
120+
'database' => 'database_db_name',
121+
'username' => 'database_db_user',
122+
'password' => 'database_db_pass',
123+
'host' => 'database_db_host',
124+
'port' => 'database_db_port',
125+
'charset' => 'mysql_utf8mb3',
126+
'collation' => 'mysql_utf8mb3_bin',
90127
'driver' => 'mysql',
91128
'prefix' => '',
92129
],

.vortex/installer/tests/Fixtures/install/_baseline/web/sites/default/settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
'password' => getenv('DATABASE_PASSWORD') ?: getenv('MARIADB_PASSWORD') ?: 'drupal',
124124
'host' => getenv('DATABASE_HOST') ?: getenv('MARIADB_HOST') ?: 'localhost',
125125
'port' => getenv('DATABASE_PORT') ?: getenv('MARIADB_PORT') ?: '',
126+
'charset' => getenv('DATABASE_CHARSET') ?: getenv('MARIADB_CHARSET') ?: getenv('MYSQL_CHARSET') ?: 'utf8mb4',
127+
'collation' => getenv('DATABASE_COLLATION') ?: getenv('MARIADB_COLLATION') ?: getenv('MYSQL_COLLATION') ?: 'utf8mb4_general_ci',
126128
'prefix' => '',
127129
'driver' => 'mysql',
128130
],

.vortex/installer/tests/Fixtures/install/hosting_acquia/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# The default user under which the containers should run.
1313
x-user: &default-user
14-
@@ -56,8 +56,8 @@
14+
@@ -60,8 +60,8 @@
1515
# Path to configuration files.
1616
DRUPAL_CONFIG_PATH: ${DRUPAL_CONFIG_PATH:-/app/config/default}
1717
# Drupal file paths.
@@ -22,7 +22,7 @@
2222
DRUPAL_TEMPORARY_FILES: ${DRUPAL_TEMPORARY_FILES:-/tmp}
2323
# Drupal Shield credentials.
2424
DRUPAL_SHIELD_USER: ${DRUPAL_SHIELD_USER:-}
25-
@@ -95,8 +95,8 @@
25+
@@ -99,8 +99,8 @@
2626
CLI_IMAGE: *cli-image
2727
WEBROOT: "${WEBROOT:-web}"
2828
DRUPAL_CONFIG_PATH: ${DRUPAL_CONFIG_PATH:-/app/config/default}

.vortex/installer/tests/Fixtures/install/hosting_acquia/docroot/sites/default/settings.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
'password' => getenv('DATABASE_PASSWORD') ?: getenv('MARIADB_PASSWORD') ?: 'drupal',
124124
'host' => getenv('DATABASE_HOST') ?: getenv('MARIADB_HOST') ?: 'localhost',
125125
'port' => getenv('DATABASE_PORT') ?: getenv('MARIADB_PORT') ?: '',
126+
'charset' => getenv('DATABASE_CHARSET') ?: getenv('MARIADB_CHARSET') ?: getenv('MYSQL_CHARSET') ?: 'utf8mb4',
127+
'collation' => getenv('DATABASE_COLLATION') ?: getenv('MARIADB_COLLATION') ?: getenv('MYSQL_COLLATION') ?: 'utf8mb4_general_ci',
126128
'prefix' => '',
127129
'driver' => 'mysql',
128130
],

.vortex/installer/tests/Fixtures/install/hosting_lagoon/docker-compose.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
+# Note that these variables are not read from here in Lagoon environment.
66
x-environment: &default-environment
77
TZ: ${TZ:-Australia/Melbourne}
8-
# Local development URL.
9-
@@ -86,6 +87,10 @@
8+
# Pass-through 'CI' variable used to identify the CI environment.
9+
@@ -90,6 +91,10 @@
1010
# Mount volumes from the ssh-agent running in Pygmy to inject host SSH key into container. See https://pygmy.readthedocs.io/en/master/ssh_agent/
1111
volumes_from: ### Local overrides to mount host SSH keys. Automatically removed in CI.
1212
- container:amazeeio-ssh-agent ### Local overrides to mount host SSH keys. Automatically removed in CI.
@@ -17,7 +17,7 @@
1717

1818
nginx:
1919
build:
20-
@@ -106,6 +111,11 @@
20+
@@ -110,6 +115,11 @@
2121
networks:
2222
- default # This is a standard network and is used for all other environments, where requests routing is not required and/or not supported.
2323
- amazeeio-network ### This network is supported by Pygmy and used to route all requests to host machine locally. Removed in CI.
@@ -29,7 +29,7 @@
2929

3030
# PHP FPM container. All web requests are going through this container.
3131
php:
32-
@@ -119,6 +129,11 @@
32+
@@ -123,6 +133,11 @@
3333
<<: *default-environment
3434
depends_on:
3535
- cli
@@ -41,7 +41,7 @@
4141

4242
database:
4343
build:
44-
@@ -131,9 +146,13 @@
44+
@@ -135,9 +150,13 @@
4545
<<: *default-environment
4646
ports:
4747
- "3306" # Database port in a container. Find port on host with `ahoy info` or `docker compose port database 3306`.
@@ -55,7 +55,7 @@
5555

5656
solr:
5757
build:
58-
@@ -149,6 +168,8 @@
58+
@@ -153,6 +172,8 @@
5959
- "8983" # Solr port in a container. Find port on host with `ahoy info` or `docker compose port solr 8983`.
6060
volumes:
6161
- solr:/var/solr
@@ -64,7 +64,7 @@
6464

6565
clamav:
6666
build:
67-
@@ -161,6 +182,10 @@
67+
@@ -165,6 +186,10 @@
6868
<< : *default-environment
6969
networks:
7070
- default
@@ -75,7 +75,7 @@
7575

7676
# Chrome container, used for browser testing.
7777
chrome:
78-
@@ -173,6 +198,8 @@
78+
@@ -177,6 +202,8 @@
7979
<<: *default-environment
8080
depends_on:
8181
- cli
@@ -84,7 +84,7 @@
8484

8585
# Helper container to wait for services to become available.
8686
wait_dependencies:
87-
@@ -182,6 +209,8 @@
87+
@@ -186,6 +213,8 @@
8888
- database
8989
- clamav
9090
command: database:3306 clamav:3310

0 commit comments

Comments
 (0)