Archived
1
0
Fork 0

Minor refactoring for 2.1.2

This commit is contained in:
Varakh 2019-08-07 17:34:39 +02:00
parent afba893623
commit c3e43617e4
6 changed files with 37 additions and 23 deletions

View file

@ -1,5 +1,9 @@
# CHANGELOG # CHANGELOG
## 2.1.2 - 2019/08/07
* Minor refactoring
* Update documentation
## 2.1.1 - 2019/08/07 ## 2.1.1 - 2019/08/07
* Updated translation * Updated translation

View file

@ -37,8 +37,9 @@ you're using docker as deployment type.
* Logs are saved in `/var/www/html/application/log` for docker containers. You should create a volume * Logs are saved in `/var/www/html/application/log` for docker containers. You should create a volume
for this location if you're using docker as deployment type. for this location if you're using docker as deployment type.
**Important**: Ensure that host binds have permissions set up properly. The user which is used in the docker container is `www-data` with **Important**: Ensure that host binds have permissions set up properly. The user which is used in the docker container
id `82`. If, e.g. logs are host bound, then execute `chown -R 82:82 host/path/to/log`. The same holds true for snapshots. is `www-data` with id `82`. If, e.g. logs are host bound, then execute `chown -R 82:82 host/path/to/log`.
The same holds true for snapshots.
### Usage with docker-compose ### Usage with docker-compose
The recommended way is to use docker-compose. The `network_mode = "host"` is required in order to show correct IP The recommended way is to use docker-compose. The `network_mode = "host"` is required in order to show correct IP

View file

@ -64,4 +64,21 @@ class EnvConstants
* Log level * Log level
*/ */
const LOG_LEVEL = "log_level"; const LOG_LEVEL = "log_level";
/**
* Required attributes
*/
const ENV_REQUIRED = [
EnvConstants::SITE_TITLE,
EnvConstants::SITE_LANGUAGE,
EnvConstants::SITE_DATE_FORMAT,
EnvConstants::THEME,
EnvConstants::THEME_CACHE,
EnvConstants::TEAMSPEAK_HOST,
EnvConstants::TEAMSPEAK_QUERY_PORT,
EnvConstants::TEAMSPEAK_USER,
EnvConstants::TEAMSPEAK_LOG_LINES,
EnvConstants::LOG_NAME,
EnvConstants::LOG_LEVEL
];
} }

View file

@ -7,6 +7,9 @@ RUN apk add --no-cache git \
# adjust nginx # adjust nginx
COPY docker/default.conf /etc/nginx/conf.d/default.conf COPY docker/default.conf /etc/nginx/conf.d/default.conf
COPY docker/nginx.conf /etc/nginx/nginx.conf COPY docker/nginx.conf /etc/nginx/nginx.conf
RUN sed -i "s|upload_max_filesize = 2M|upload_max_filesize = 1024M|g" /etc/php/7.3/php.ini \
&& sed -i "s|post_max_size = 8M|post_max_size = 1024M|g" /etc/php/7.3/php.ini \
&& sed -i "s|max_execution_time = 30|max_execution_time = 86400|g" /etc/php/7.3/php.ini
# copy application and set permissions # copy application and set permissions
COPY config/ /var/www/html/application/config/ COPY config/ /var/www/html/application/config/
@ -16,10 +19,6 @@ COPY src/ /var/www/html/application/src/
COPY composer.json /var/www/html/application/composer.json COPY composer.json /var/www/html/application/composer.json
RUN mkdir -p /var/www/html/application/bin/ \ RUN mkdir -p /var/www/html/application/bin/ \
&& mkdir -p /var/www/html/application/cache/ \ && mkdir -p /var/www/html/application/cache/ \
&& chmod -R 777 /var/www/html/application/data/ \
&& mkdir -p /var/www/html/application/log/ \
&& touch /var/www/html/application/log/application.log \
&& chmod 777 /var/www/html/application/log/application.log \
&& chown -R www-data:www-data /var/www/html/application && chown -R www-data:www-data /var/www/html/application
# initialize app # initialize app

View file

@ -215,7 +215,7 @@ $container['notFoundHandler'] = function ($container) {
$container['errorHandler'] = function ($container) { $container['errorHandler'] = function ($container) {
return function (Request $request, Response $response, $exception) use ($container) { return function (Request $request, Response $response, $exception) use ($container) {
// handle all teamspeak exceptions with a flash message // handle all TeamSpeak exceptions with a flash message
if ($exception instanceof TSException) { if ($exception instanceof TSException) {
$container->flash->addMessage('error', $exception->getMessage()); $container->flash->addMessage('error', $exception->getMessage());
@ -230,9 +230,7 @@ $container['errorHandler'] = function ($container) {
'content' => $exception->getMessage() 'content' => $exception->getMessage()
]); ]);
} }
} } else {
// all others are 500
else {
$container['logger']->error($container['translator']->trans('log.internal.application.error'), [ $container['logger']->error($container['translator']->trans('log.internal.application.error'), [
'file' => $exception->getFile(), 'file' => $exception->getFile(),
'line' => $exception->getLine(), 'line' => $exception->getLine(),

View file

@ -1,6 +1,7 @@
<?php <?php
use Dotenv\Dotenv; use Dotenv\Dotenv;
use Dotenv\Exception\ValidationException;
use Monolog\Handler\ErrorLogHandler; use Monolog\Handler\ErrorLogHandler;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Monolog\Logger; use Monolog\Logger;
@ -27,19 +28,13 @@ class BootstrapHelper
if (file_exists($envFile)) { if (file_exists($envFile)) {
$env = new Dotenv(realpath($envPath), EnvConstants::ENV_FILE); $env = new Dotenv(realpath($envPath), EnvConstants::ENV_FILE);
$res = $env->load(); $res = $env->load();
$env->required([
EnvConstants::SITE_TITLE, try {
EnvConstants::SITE_LANGUAGE, $env->required(EnvConstants::ENV_REQUIRED);
EnvConstants::SITE_DATE_FORMAT, } catch (ValidationException $e) {
EnvConstants::THEME, die($e->getMessage());
EnvConstants::THEME_CACHE, }
EnvConstants::TEAMSPEAK_HOST,
EnvConstants::TEAMSPEAK_QUERY_PORT,
EnvConstants::TEAMSPEAK_USER,
EnvConstants::TEAMSPEAK_LOG_LINES,
EnvConstants::LOG_NAME,
EnvConstants::LOG_LEVEL
]);
return $res; return $res;
} else { } else {
die('No environment file found in ' . realpath($envFile)); die('No environment file found in ' . realpath($envFile));