summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Tushev <tushev@users.noreply.github.com>2021-11-30 03:30:57 +0500
committerGitHub <noreply@github.com>2021-11-29 22:30:57 +0000
commit2857b4b3f1d3aecbb80d1ec5497ff8a2801ef44a (patch)
tree4f663d5b5a56b3a3a2f7a1056aa8468d724a376b
parentf4dbcf523a27ba240b29dcf92b24d0c20544b42d (diff)
Added fetching autoconfig data from Docker secrets (#1516)
* Added fetching autoconfig data from Docker secrets Signed-off-by: Simon Tushev <tushev@users.noreply.github.com> * Docker secrets now have priority over ENV variables; improved README.md Signed-off-by: Simon Tushev <tushev@users.noreply.github.com>
-rw-r--r--.config/autoconfig.php14
-rw-r--r--README.md6
2 files changed, 19 insertions, 1 deletions
diff --git a/.config/autoconfig.php b/.config/autoconfig.php
index f01f18d6..92ad2a1c 100644
--- a/.config/autoconfig.php
+++ b/.config/autoconfig.php
@@ -6,6 +6,13 @@ if (getenv('SQLITE_DATABASE')) {
$AUTOCONFIG['dbtype'] = 'sqlite';
$AUTOCONFIG['dbname'] = getenv('SQLITE_DATABASE');
$autoconfig_enabled = true;
+} elseif (getenv('MYSQL_DATABASE_FILE') && getenv('MYSQL_USER_FILE') && getenv('MYSQL_PASSWORD_FILE') && getenv('MYSQL_HOST')) {
+ $AUTOCONFIG['dbtype'] = 'mysql';
+ $AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('MYSQL_DATABASE_FILE')));
+ $AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('MYSQL_USER_FILE')));
+ $AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('MYSQL_PASSWORD_FILE')));
+ $AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
+ $autoconfig_enabled = true;
} elseif (getenv('MYSQL_DATABASE') && getenv('MYSQL_USER') && getenv('MYSQL_PASSWORD') && getenv('MYSQL_HOST')) {
$AUTOCONFIG['dbtype'] = 'mysql';
$AUTOCONFIG['dbname'] = getenv('MYSQL_DATABASE');
@@ -13,6 +20,13 @@ if (getenv('SQLITE_DATABASE')) {
$AUTOCONFIG['dbpass'] = getenv('MYSQL_PASSWORD');
$AUTOCONFIG['dbhost'] = getenv('MYSQL_HOST');
$autoconfig_enabled = true;
+} elseif (getenv('POSTGRES_DB_FILE') && getenv('POSTGRES_USER_FILE') && getenv('POSTGRES_PASSWORD_FILE') && getenv('POSTGRES_HOST')) {
+ $AUTOCONFIG['dbtype'] = 'pgsql';
+ $AUTOCONFIG['dbname'] = trim(file_get_contents(getenv('POSTGRES_DB_FILE')));
+ $AUTOCONFIG['dbuser'] = trim(file_get_contents(getenv('POSTGRES_USER_FILE')));
+ $AUTOCONFIG['dbpass'] = trim(file_get_contents(getenv('POSTGRES_PASSWORD_FILE')));
+ $AUTOCONFIG['dbhost'] = getenv('POSTGRES_HOST');
+ $autoconfig_enabled = true;
} elseif (getenv('POSTGRES_DB') && getenv('POSTGRES_USER') && getenv('POSTGRES_PASSWORD') && getenv('POSTGRES_HOST')) {
$AUTOCONFIG['dbtype'] = 'pgsql';
$AUTOCONFIG['dbname'] = getenv('POSTGRES_DB');
diff --git a/README.md b/README.md
index 1ebc5221..e931557e 100644
--- a/README.md
+++ b/README.md
@@ -118,7 +118,9 @@ __PostgreSQL__:
- `POSTGRES_PASSWORD` Password for the database user using postgres.
- `POSTGRES_HOST` Hostname of the database server using postgres.
-If you set any values, they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):
+As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. See [Docker secrets](#docker=secrets) section below.
+
+If you set any group of values (i.e. all of `MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_HOST`), they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):
- `NEXTCLOUD_ADMIN_USER` Name of the Nextcloud admin user.
- `NEXTCLOUD_ADMIN_PASSWORD` Password for the Nextcloud admin user.
@@ -376,6 +378,8 @@ secrets:
Currently, this is only supported for `NEXTCLOUD_ADMIN_PASSWORD`, `NEXTCLOUD_ADMIN_USER`, `MYSQL_DATABASE`, `MYSQL_PASSWORD`, `MYSQL_USER`, `POSTGRES_DB`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, `REDIS_HOST_PASSWORD` and `SMTP_PASSWORD`.
+If you set any group of values (i.e. all of `MYSQL_DATABASE_FILE`, `MYSQL_USER_FILE`, `MYSQL_PASSWORD_FILE`, `MYSQL_HOST`), the script will not use the corresponding group of environment variables (`MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_HOST`)
+
# Make your Nextcloud available from the internet
Until here, your Nextcloud is just available from your docker host. If you want your Nextcloud available from the internet adding SSL encryption is mandatory.