Skip to content

Commit f2732fe

Browse files
author
Yevhen Miroshnychenko
authored
MAGECLOUD-4925: Ability to support custom database parameters in docker image (#140)
1 parent fa11090 commit f2732fe

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

dist/mysql/mariadb.conf.d/example.cnf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# This directory will be mounted in the 'db' service as '/etc/mysql/mariadb.conf.d'
3+
# and read by /etc/mysql/conf.d/mariadb.cnf.
4+
# All *.cnf files from the configuration directory will be applied to MariaDB configuration
5+
#
6+
7+
[client]
8+
#
9+
# Default is Latin1, if you need UTF-8 set this (also in server section)
10+
#default-character-set = utf8
11+
#
12+
13+
[mysqld]
14+
#
15+
# * Character sets
16+
#
17+
# Default is Latin1, if you need UTF-8 set all this (also in client section)
18+
#
19+
#character_set_server = utf8
20+
#collation_server = utf8_general_ci

src/Compose/BuilderInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ interface BuilderInterface
5656
public const VOLUME_MAGENTO_DEV = 'magento-dev';
5757
public const VOLUME_DOCKER_MNT = 'docker-mnt';
5858
public const VOLUME_DOCKER_ETRYPOINT = 'docker-entrypoint';
59+
public const VOLUME_MARIADB_CONF = 'mariadb-conf';
5960

6061
public const SYNC_ENGINE_NATIVE = 'native';
6162

src/Compose/DeveloperBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ public function getPath(): string
158158
*/
159159
private function getMagentoVolumes(Repository $config): array
160160
{
161-
$target = self::DIR_MAGENTO;
162-
163161
if ($config->get(self::KEY_SYNC_ENGINE) !== self::SYNC_ENGINE_NATIVE) {
164-
$target .= ':nocopy';
162+
return [
163+
self::VOLUME_MAGENTO_SYNC . ':' . self::DIR_MAGENTO . ':nocopy'
164+
];
165165
}
166166

167167
return [
168-
self::VOLUME_MAGENTO_SYNC . ':' . $target . ':delegated',
168+
self::VOLUME_MAGENTO_SYNC . ':' . self::DIR_MAGENTO . ':delegated',
169169
];
170170
}
171171
}

src/Compose/ProductionBuilder.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,14 @@ public function build(Repository $config): Manager
183183
'device' => $this->resolver->getRootPath('/.docker/mysql/docker-entrypoint-initdb.d'),
184184
'o' => 'bind'
185185
]
186-
]
186+
],
187+
self::VOLUME_MARIADB_CONF => [
188+
'driver_opts' => [
189+
'type' => 'none',
190+
'device' => $this->resolver->getRootPath('/.docker/mysql/mariadb.conf.d'),
191+
'o' => 'bind',
192+
],
193+
],
187194
];
188195

189196
if ($this->hasSelenium($config)) {
@@ -220,6 +227,16 @@ public function build(Repository $config): Manager
220227
$volumes[$volumeName] = $syncConfig;
221228
}
222229

230+
if ($config->get(self::KEY_SYNC_ENGINE) === self::SYNC_ENGINE_MOUNT) {
231+
$volumes[self::VOLUME_MAGENTO] = [
232+
'driver_opts' => [
233+
'type' => 'none',
234+
'device' => $this->resolver->getRootPath(),
235+
'o' => 'bind'
236+
]
237+
];
238+
}
239+
223240
$manager->addVolumes($volumes);
224241

225242
$volumesBuild = $this->volumeResolver->normalize(array_merge(
@@ -249,7 +266,8 @@ public function build(Repository $config): Manager
249266
'volumes' => array_merge(
250267
[
251268
self::VOLUME_MAGENTO_DB . ':/var/lib/mysql',
252-
self::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d'
269+
self::VOLUME_DOCKER_ETRYPOINT . ':/docker-entrypoint-initdb.d',
270+
self::VOLUME_MARIADB_CONF . ':/etc/mysql/mariadb.conf.d',
253271
],
254272
$volumesMount
255273
)

0 commit comments

Comments
 (0)