Merge pull request #2 from AlexVeeBee/master

Update installer and cache config
This commit is contained in:
deffcolony 2025-04-23 17:34:22 +02:00 committed by GitHub
commit 64edc11a23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 169 additions and 162 deletions

View File

@ -53,7 +53,8 @@ MYSQL_PASSWORD=vichan!
MYSQL_ROOT_PASSWORD=vichan!!
# Redis
VICHAN_REDIS_HOST=redis
VICHAN_REDIS_PORT=6379
VICHAN_REDIS_PASSWORD=redis!
# Cache Settings
VICHAN_CACHE_ENGINE=redis
VICHAN_CACHE_HOST=redis
VICHAN_CACHE_PORT=6379
VICHAN_CACHE_PASSWORD=redis!

View File

@ -39,10 +39,11 @@ services:
VICHAN_MYSQL_PASSWORD: ${VICHAN_MYSQL_PASSWORD}
# Security
VICHAN_SECURE_LOGIN_ONLY: ${VICHAN_SECURE_LOGIN_ONLY}
# Redis settings
VICHAN_REDIS_HOST: ${VICHAN_REDIS_HOST}
VICHAN_REDIS_PORT: ${VICHAN_REDIS_PORT}
VICHAN_REDIS_PASSWORD: ${VICHAN_REDIS_PASSWORD}
# Cache settings
VICHAN_CACHE_ENGINE: ${VICHAN_CACHE_ENGINE}
VICHAN_CACHE_HOST: ${VICHAN_CACHE_HOST}
VICHAN_CACHE_PORT: ${VICHAN_CACHE_PORT}
VICHAN_CACHE_PASSWORD: ${VICHAN_CACHE_PASSWORD}
# Cookies
VICHAN_COOKIES_MOD: ${VICHAN_COOKIES_MOD}
# Flood Control
@ -88,10 +89,10 @@ services:
volumes:
- ./local-instances/${INSTANCE:-0}/redis:/data
environment:
REDIS_PASSWORD: ${VICHAN_REDIS_PASSWORD}
command: redis-server --requirepass ${VICHAN_REDIS_PASSWORD}
REDIS_PASSWORD: ${VICHAN_CACHE_PASSWORD}
command: redis-server --requirepass ${VICHAN_CACHE_PASSWORD}
healthcheck:
test: ["CMD", "redis-cli", "-a", "${VICHAN_REDIS_PASSWORD}", "ping"]
test: ["CMD", "redis-cli", "-a", "${VICHAN_CACHE_PASSWORD}", "ping"]
interval: 10s
timeout: 5s
retries: 5

View File

@ -47,7 +47,7 @@ RUN apk add --no-cache \
&& pecl install -o -f igbinary \
&& pecl install redis \
&& pecl install imagick \
$$ docker-php-ext-enable \
&& docker-php-ext-enable \
igbinary \
redis \
imagick \

View File

@ -20,12 +20,22 @@ class Cache {
$config['cache']['memcached']
);
case 'redis':
$host = $config['cache']['redis'][0] ?? 'localhost';
$port = $config['cache']['redis'][1] ?? 6379;
$password = $config['cache']['redis'][2] ?? '';
$database = $config['cache']['redis'][3] ?? 1;
$host = getenv('VICHAN_CACHE_HOST') ?: $host;
$port = getenv('VICHAN_CACHE_PORT') ?: $port;
$password = getenv('VICHAN_CACHE_PASSWORD') ?: $password;
$database = getenv('VICHAN_CACHE_DATABASE') ?: $database;
return new RedisCacheDriver(
$config['cache']['prefix'],
$config['cache']['redis'][0],
$config['cache']['redis'][1],
$config['cache']['redis'][2],
$config['cache']['redis'][3]
$host,
$port,
$password,
$database
);
case 'apcu':
return new ApcuCacheDriver;

View File

@ -137,32 +137,16 @@
* ====================
*/
// Determine if Redis is configured via environment variables
$redis_enabled = getenv('VICHAN_REDIS_HOST') !== false && getenv('VICHAN_REDIS_PORT') !== false;
// Configure cache
if ($redis_enabled) {
$config['cache']['enabled'] = 'redis';
$config['cache']['redis'] = [
'host' => getenv('VICHAN_REDIS_HOST') ?: 'localhost',
'port' => (int)(getenv('VICHAN_REDIS_PORT') ?: 6379),
'password' => getenv('VICHAN_REDIS_PASSWORD') ?: '',
'database' => 1,
];
} else {
$config['cache']['enabled'] = 'php';
}
$config['cache']['redis'] = array(
'host' => 'localhost',
'port' => 6379,
'password' => '',
'database' => 1
);
// Configure sessions to use Redis if enabled
if ($redis_enabled) {
$config['session']['enabled'] = 'redis';
$config['session']['redis'] = [
'host' => getenv('VICHAN_REDIS_HOST') ?: 'localhost',
'port' => (int)(getenv('VICHAN_REDIS_PORT') ?: 6379),
'password' => getenv('VICHAN_REDIS_PASSWORD') ?: '',
'database' => 1,
];
}
// Determine if Redis is configured via environment variables
getenv('VICHAN_CACHE_ENGINE') && $config['cache']['enabled'] = getenv('VICHAN_CACHE_ENGINE');
// Cache timeout for cached objects
$config['cache']['timeout'] = 60 * 60 * 48; // 48 hours
@ -1869,6 +1853,18 @@
// Enable public logs? 0: NO, 1: YES, 2: YES, but drop names
$config['public_logs'] = 0;
/*
* ====================
* Container settings
* ===================
*/
$isDocker = is_file("/.dockerenv") || is_file("/run/.containerenv");
$isKubernetes = is_file("/var/run/secrets/kubernetes.io/serviceaccount/namespace");
$config['is_container'] = $isDocker || $isKubernetes ? true : false;
$config['is_docker'] = $isDocker;
$config['is_kubernetes'] = $isKubernetes;
/*
* ====================
* Events (PHP 5.3.0+)

View File

@ -684,7 +684,7 @@ if ($step == 0) {
$page['body'] = '
<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" disabled>' . htmlentities(file_get_contents('LICENSE.md')) . '</textarea>
<p style="text-align:center">
<button onclick="window.location.href=\'?step=1\'">I have read and understood the agreement. Proceed to installation.</button>
<a href="?step=1">I have read and understood the agreement. Proceed to installation.</a>
</p>';
echo Element('page.html', $page);
@ -1089,7 +1089,6 @@ if ($step == 0) {
'<p><strong>Important:</strong> For security, please change the administrator password immediately after logging in.</p>' .
'<p style="text-align:center"><button onclick="window.location.href=\'/mod.php\'">Go to Admin Panel</button></p></div>';
$boards = listBoards();
foreach ($boards as &$_board) {
setupBoard($_board);