Skip to content
Snippets Groups Projects
Commit ed3517bd authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

db in docker

parent 5de52a6f
No related branches found
No related tags found
No related merge requests found
......@@ -8,5 +8,7 @@ error_reporting=22519
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.revalidate_freq=0
opcache.validate_timestamps=1
opcache.jit=tracing
opcache.jit_buffer_size=100M
......@@ -149,7 +149,6 @@ final class Compile extends Command
// Nginx
$creator->addService('nginx', 'nginx:alpine', [
'networks' => ['code-network'],
'depends_on' => ['redis-server', 'memcached-server'],
'ports' => array_merge(
Config::getInstance()->get('default') ? ['80:80', '443:443'] : [],
......@@ -164,13 +163,20 @@ final class Compile extends Command
]);
// DB
$creator->addService('db', 'mariadb:latest', [
$creator->addService('db', 'mariadb', [
'container_name' => 'db',
'networks' => ['code-network'],
'ports' => ['3306:3306'],
'restart' => 'unless-stopped',
'environment' => [
'MARIADB_RANDOM_ROOT_PASSWORD' => true,
'MARIADB_ROOT_PASSWORD' => 'rootpwd',
'MARIADB_USER' => 'studip',
'MARIADB_PASSWORD' => 'studip',
'MARIADB_MYSQL_LOCALHOST_USER' => 'root',
'MARIADB_AUTO_UPGRADE' => true,
],
'volumes' => ['db-data:/var/lib/mysql'],
]);
$creator->addVolume('db-data');
$mounts = [
"{$compiledPath}/nginx.conf" => 'conf.d/default.conf',
......@@ -201,9 +207,8 @@ final class Compile extends Command
'dockerfile' => "{$cwd}/config/docker-files/{$version}-Dockerfile",
],
'environment' => [
'MYSQL_HOST' => 'host.docker.internal',
'MYSQL_HOST' => 'db',
],
'networks' => ['code-network'],
'depends_on' => ['db'],
]);
......@@ -231,18 +236,9 @@ final class Compile extends Command
}
// Other needed images
$creator->addService('memcached-server', 'memcached:latest', [
'networks' => ['code-network'],
]);
$creator->addService('redis-server', 'redis:latest', [
'networks' => ['code-network'],
]);
$creator->addNetwork('code-network', [
'driver' => 'bridge',
]);
$creator->addService('memcached-server', 'memcached:latest');
$creator->addService('redis-server', 'redis:latest');
return $creator->dump();
}
......
......@@ -50,6 +50,17 @@ final class DockerComposeConfiguration extends ConfigurationCreator
$this->addConfiguration('networks', $config, $network);
}
public function addVolume(string $volume): void
{
$config = $this->getConfiguration('volumes', []);
if (array_key_exists($volume, $config)) {
throw new \Exception('Volume "' . $volume . '" already exists');
}
$this->addConfiguration('volumes', ['name' => $volume], $volume);
}
public function dump(): string
{
return Yaml::dump($this->getConfiguration(), 128);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment