diff --git a/docker/README.md b/docker/README.md index 2cc0b5b9..c7627d7f 100644 --- a/docker/README.md +++ b/docker/README.md @@ -157,6 +157,7 @@ This is the complete list of supported env vars: * **mysql** or **maria** -> `3306` * **postgres** -> `5432` * **mssql** -> `1433` +* `DB_UNIX_SOCKET`: Alternatively to the `DB_HOST`, you can provide this to connect through unix sockets when using `mysql`, `maria` or `postgres` drivers. * `DISABLE_TRACK_PARAM`: The name of a query param that can be used to visit short URLs avoiding the visit to be tracked. This feature won't be available if not value is provided. * `DELETE_SHORT_URL_THRESHOLD`: The amount of visits on short URLs which will not allow them to be deleted. Defaults to `15`. * `VALIDATE_URLS`: Boolean which tells if shlink should validate a status 20x is returned (after following redirects) when trying to shorten a URL. Defaults to `false`. @@ -215,7 +216,11 @@ docker run \ shlinkio/shlink:stable ``` -## Provide config via volumes +## [DEPRECATED] Provide config via volumes + +> As of v2.5.0, providing config through volumes is deprecated, and no new options will be added anymore. Use env vars instead. +> +> Support for config options through volumes will be removed in Shlink v3.0.0 Rather than providing custom configuration via env vars, it is also possible ot provide config files in json format. diff --git a/docker/config/shlink_in_docker.local.php b/docker/config/shlink_in_docker.local.php index c4502b7c..c6d7f69e 100644 --- a/docker/config/shlink_in_docker.local.php +++ b/docker/config/shlink_in_docker.local.php @@ -34,6 +34,7 @@ $helper = new class { public function getDbConfig(): array { $driver = env('DB_DRIVER'); + $isMysql = contains(['maria', 'mysql'], $driver); if ($driver === null || $driver === 'sqlite') { return [ 'driver' => 'pdo_sqlite', @@ -41,7 +42,7 @@ $helper = new class { ]; } - $driverOptions = ! contains(['maria', 'mysql'], $driver) ? [] : [ + $driverOptions = ! $isMysql ? [] : [ // 1002 -> PDO::MYSQL_ATTR_INIT_COMMAND 1002 => 'SET NAMES utf8', // 1000 -> PDO::MYSQL_ATTR_USE_BUFFERED_QUERY @@ -52,9 +53,10 @@ $helper = new class { 'dbname' => env('DB_NAME', 'shlink'), 'user' => env('DB_USER'), 'password' => env('DB_PASSWORD'), - 'host' => env('DB_HOST'), + 'host' => env('DB_HOST', $driver === 'postgres' ? env('DB_UNIX_SOCKET') : null), 'port' => env('DB_PORT', self::DB_PORTS_MAP[$driver]), 'driverOptions' => $driverOptions, + 'unix_socket' => $isMysql ? env('DB_UNIX_SOCKET') : null, ]; } diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php index aebeb2c3..b578799b 100644 --- a/module/Core/src/Config/SimplifiedConfigParser.php +++ b/module/Core/src/Config/SimplifiedConfigParser.php @@ -15,6 +15,7 @@ use function Functional\contains; use function Functional\reduce_left; use function uksort; +/** @deprecated */ class SimplifiedConfigParser { private const SIMPLIFIED_CONFIG_MAPPING = [