From 9dc6ea9eebf38b1a8492930acc9135c07839e302 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 6 Oct 2019 11:38:23 +0200 Subject: [PATCH] Documented how to use maria db with docker image --- composer.json | 2 +- docker/README.md | 8 ++++---- docker/config/shlink_in_docker.local.php | 5 ++++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index 70643969..a8a95dba 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "predis/predis": "^1.1", "shlinkio/shlink-common": "^2.0", "shlinkio/shlink-event-dispatcher": "^1.0", - "shlinkio/shlink-installer": "^2.0", + "shlinkio/shlink-installer": "^2.1", "shlinkio/shlink-ip-geolocation": "^1.0", "symfony/console": "^4.3", "symfony/filesystem": "^4.3", diff --git a/docker/README.md b/docker/README.md index 9f62c818..aff3d997 100644 --- a/docker/README.md +++ b/docker/README.md @@ -56,16 +56,16 @@ docker exec -it shlink_container shlink The image comes with a working sqlite database, but in production you will probably want to usa a distributed database. -It is possible to use a set of env vars to make this shlink instance interact with an external MySQL or PostgreSQL database. +It is possible to use a set of env vars to make this shlink instance interact with an external MySQL, MariaDB or PostgreSQL database. -* `DB_DRIVER`: **[Mandatory]**. Use the value **mysql** or **postgres** to prevent the sqlite database to be used. +* `DB_DRIVER`: **[Mandatory]**. Use the value **mysql**, **maria** or **postgres** to prevent the sqlite database to be used. * `DB_NAME`: [Optional]. The database name to be used. Defaults to **shlink**. * `DB_USER`: **[Mandatory]**. The username credential for the database server. * `DB_PASSWORD`: **[Mandatory]**. The password credential for the database server. * `DB_HOST`: **[Mandatory]**. The host name of the server running the database engine. * `DB_PORT`: [Optional]. The port in which the database service is running. * Default value is based on the driver: - * **mysql** -> `3306` + * **mysql** or **maria** -> `3306` * **postgres** -> `5432` > PostgreSQL is supported since v1.16.1 of this image. Do not try to use it with previous versions. @@ -93,7 +93,7 @@ This is the complete list of supported env vars: * `SHORT_DOMAIN_HOST`: The custom short domain used for this shlink instance. For example **doma.in**. * `SHORT_DOMAIN_SCHEMA`: Either **http** or **https**. * `SHORTCODE_CHARS`: A charset to use when building short codes. Only needed when using more than one shlink instance ([Multi instance considerations](#multi-instance-considerations)). -* `DB_DRIVER`: **sqlite** (which is the default value), **mysql** or **postgres**. +* `DB_DRIVER`: **sqlite** (which is the default value), **mysql**, **maria** or **postgres**. * `DB_NAME`: The database name to be used when using an external database driver. Defaults to **shlink**. * `DB_USER`: The username credential to be used when using an external database driver. * `DB_PASSWORD`: The password credential to be used when using an external database driver. diff --git a/docker/config/shlink_in_docker.local.php b/docker/config/shlink_in_docker.local.php index ecfde4dc..d0744358 100644 --- a/docker/config/shlink_in_docker.local.php +++ b/docker/config/shlink_in_docker.local.php @@ -11,6 +11,7 @@ use function explode; use function file_exists; use function file_get_contents; use function file_put_contents; +use function Functional\contains; use function implode; use function Shlinkio\Shlink\Common\env; use function sprintf; @@ -22,10 +23,12 @@ $helper = new class { private const BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; private const DB_DRIVERS_MAP = [ 'mysql' => 'pdo_mysql', + 'maria' => 'pdo_mysql', 'postgres' => 'pdo_pgsql', ]; private const DB_PORTS_MAP = [ 'mysql' => '3306', + 'maria' => '3306', 'postgres' => '5432', ]; @@ -85,7 +88,7 @@ $helper = new class { ]; } - $driverOptions = $driver !== 'mysql' ? [] : [ + $driverOptions = ! contains(['maria', 'mysql'], $driver) ? [] : [ // PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', 1002 => 'SET NAMES utf8', ];