Skip to content

Commit

Permalink
MariaDB support (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Apr 20, 2021
1 parent d1a91b0 commit 8060885
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected function gatherServicesWithSymfonyMenu()
return $this->choice('Which services would you like to install?', [
'mysql',
'pgsql',
'mariadb',
'redis',
'memcached',
'meilisearch',
Expand All @@ -69,7 +70,7 @@ protected function buildDockerCompose(array $services)
{
$depends = collect($services)
->filter(function ($service) {
return in_array($service, ['mysql', 'pgsql', 'redis', 'selenium']);
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'selenium']);
})->map(function ($service) {
return " - {$service}";
})->whenNotEmpty(function ($collection) {
Expand All @@ -82,7 +83,7 @@ protected function buildDockerCompose(array $services)

$volumes = collect($services)
->filter(function ($service) {
return in_array($service, ['mysql', 'pgsql', 'redis', 'meilisearch']);
return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch']);
})->map(function ($service) {
return " sail{$service}:\n driver: local";
})->whenNotEmpty(function ($collection) {
Expand Down Expand Up @@ -115,6 +116,8 @@ protected function replaceEnvVariables(array $services)
$environment = str_replace('DB_CONNECTION=mysql', "DB_CONNECTION=pgsql", $environment);
$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment);
$environment = str_replace('DB_PORT=3306', "DB_PORT=5432", $environment);
} elseif (in_array('mariadb', $services)) {
$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mariadb", $environment);
} else {
$environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=mysql", $environment);
}
Expand Down
16 changes: 16 additions & 0 deletions stubs/mariadb.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mariadb:
image: 'mariadb:10'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmariadb:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping"]
2 changes: 1 addition & 1 deletion stubs/pgsql.stub
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pgsql:
image: postgres:13
image: 'postgres:13'
ports:
- '${FORWARD_DB_PORT:-5432}:5432'
environment:
Expand Down

0 comments on commit 8060885

Please sign in to comment.