diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d7c9f8f2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +uim-index-dev/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0a9b7a83 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM indexyz/php +LABEL maintainer="Indexyz " + +COPY . /var/www +WORKDIR /var/www + +RUN cp config/.config.example.php config/.config.php && \ + chmod -R 755 storage && \ + chmod -R 777 /var/www/storage/framework/smarty/compile/ && \ + curl -SL https://getcomposer.org/installer -o composer-setup.php && \ + php composer-setup.php && \ + php composer.phar install && \ + php xcat initQQWry && \ + php xcat initdownload && \ + crontab -l | { cat; echo "30 22 * * * php /var/www/xcat sendDiaryMail"; } | crontab - && \ + crontab -l | { cat; echo "0 0 * * * php /var/www/xcat dailyjob"; } | crontab - && \ + crontab -l | { cat; echo "*/1 * * * * php /var/www/xcat checkjob"; } | crontab - && \ + crontab -l | { cat; echo "*/1 * * * * php /var/www/xcat syncnode"; } | crontab - && \ + { \ + echo '[program:crond]'; \ + echo 'command=cron -f'; \ + echo 'autostart=true'; \ + echo 'autorestart=true'; \ + echo 'killasgroup=true'; \ + echo 'stopasgroup=true'; \ + } | tee /etc/supervisor/crond.conf \ No newline at end of file diff --git a/config/.config.example.php b/config/.config.example.php index 143539f3..ec61aeba 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -218,7 +218,7 @@ $System_Config['bitpay_secret']=''; #PayJs $System_Config['payjs_mchid']=''; -$System_Config['payjs_key']=''; +$System_Config['payjs_key']=''; //其他面板显示设置------------------------------------------------------------------------------------------ @@ -324,3 +324,30 @@ if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) { $list = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $list[0]; } + + +// make replace System_Config with env +function findKeyName($name) { + global $System_Config; + foreach($System_Config as $configKey => $configValue) { + if (strtoupper($configKey) == $name) { + return $configKey; + } + } + + return NULL; +} + +foreach(getenv() as $envKey => $envValue) { + global $System_Config; + $envUpKey = strtoupper($envKey); + // Key starts with UIM_ + if (substr($envUpKey, 0 , 4) == "UIM_") { + // Vaild env key, set to System_Config + $configKey = substr($envUpKey, 4); + $realKey = findKeyName($configKey); + if ($realKey != NULL) { + $System_Config[$realKey] = $envValue; + } + } +}