1
0
Fork 0

Add ability to override any configs with env

Use environemnt variables to override any value in config.php

Also, locked version on the ubuntu image to something that actually
builds.
pull/33/head
ViViDboarder 8 years ago
parent adacce4ba1
commit 6f3dff46d1

@ -1,4 +1,4 @@
FROM ubuntu FROM ubuntu:14.04
MAINTAINER Christian Lück <christian@lueck.tv> MAINTAINER Christian Lück <christian@lueck.tv>
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \

@ -164,6 +164,18 @@ For more information check out the [official documentation](https://github.com/g
-e SELF_URL_PATH=https://example.org/ttrss -e SELF_URL_PATH=https://example.org/ttrss
``` ```
### Additional configuration
In addition to the environement variables above, it is possible to override any value in the `config.php`
by using another environment variable. Prefix the config value you want to override with `CONFIG_`
and it will replace the default value on container creation.
For example, to add the `auth_external` plugin, set the following variable:
```
-e CONFIG_PLUGINS='auth_internal, note, auth_external'
```
### Testing ttrss in foreground ### Testing ttrss in foreground
For testing purposes it's recommended to initially start this container in foreground. For testing purposes it's recommended to initially start this container in foreground.

@ -100,6 +100,15 @@ catch (PDOException $e) {
unset($pdo); unset($pdo);
} }
$config_prefix = 'CONFIG_';
foreach ($_SERVER as $name => $value) {
if (strpos($name, $config_prefix) === 0) {
$name = substr($name, strlen($config_prefix));
echo 'Getting config from env: ' . $name . PHP_EOL;
$config[$name] = $value;
}
}
$contents = file_get_contents($confpath); $contents = file_get_contents($confpath);
foreach ($config as $name => $value) { foreach ($config as $name => $value) {
$contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents); $contents = preg_replace('/(define\s*\(\'' . $name . '\',\s*)(.*)(\);)/', '$1"' . $value . '"$3', $contents);

Loading…
Cancel
Save