Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] get system-level configs from docker environment #1296

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .docker/run.php
Original file line number Diff line number Diff line change
@@ -9,11 +9,16 @@

// Get php.ini settings from PHP_INI_XXX environment variables
$php_ini = [];
$shm_env = [];
foreach(getenv() as $key => $value) {
if (strpos($key, 'PHP_INI_') === 0) {
$php_ini_key = strtolower(substr($key, 8));
$php_ini[$php_ini_key] = $value;
}
if (strpos($key, 'SHM_ENV_') === 0) {
$shm_env_key = strtolower(substr($key, 8));
$shm_env[$shm_env_key] = $value;
}
}
// deprecated one-off special configs
$php_ini['max_file_uploads'] ??= getenv('MAX_FILE_UPLOADS') ?: "100";
@@ -86,7 +91,8 @@
"max" => 8,
"spare" => 2,
"idle_timeout" => 60
]
],
"environment" => $shm_env
]
],
"settings" => [
7 changes: 6 additions & 1 deletion core/sys_config.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,12 @@
function _d(string $name, mixed $value): void
{
if (!defined($name)) {
define($name, $value);
if ($_ENV["SHM_ENV_$name"]) {
// fixme: convert from string to appropriate data type
define($name, $_ENV["SHM_ENV_$name"]);
} else {
define($name, $value);
}
}
}