refactor!: refactoring log settings
BREAKING CHANGE: delete environment variables LOG_TO_STDOUT in Dockerfilepull/87/head
parent
a47a8ab49e
commit
1b24029729
10
Dockerfile
10
Dockerfile
|
@ -16,7 +16,7 @@ ENV GID=991 \
|
||||||
DB_PORT=3306 \
|
DB_PORT=3306 \
|
||||||
FLARUM_TITLE=Docker-Flarum \
|
FLARUM_TITLE=Docker-Flarum \
|
||||||
DEBUG=false \
|
DEBUG=false \
|
||||||
LOG_TO_STDOUT=false \
|
LOG_OUTPUT=file \
|
||||||
GITHUB_TOKEN_AUTH=false \
|
GITHUB_TOKEN_AUTH=false \
|
||||||
FLARUM_PORT=8888
|
FLARUM_PORT=8888
|
||||||
|
|
||||||
|
@ -56,13 +56,15 @@ RUN apk add --no-progress --no-cache \
|
||||||
&& curl -s http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
&& curl -s http://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
|
||||||
&& sed -i 's/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/' /etc/php8/php.ini \
|
&& sed -i 's/memory_limit = .*/memory_limit = ${PHP_MEMORY_LIMIT}/' /etc/php8/php.ini \
|
||||||
&& chmod +x /usr/local/bin/composer \
|
&& chmod +x /usr/local/bin/composer \
|
||||||
&& mkdir -p /run/php /flarum/app \
|
&& mkdir -p /flarum/app /run/php /var/log/flarum \
|
||||||
&& COMPOSER_CACHE_DIR="/tmp" composer create-project flarum/flarum:$VERSION /flarum/app \
|
&& COMPOSER_CACHE_DIR="/tmp" composer create-project flarum/flarum:$VERSION /flarum/app \
|
||||||
&& composer clear-cache \
|
&& composer clear-cache \
|
||||||
&& rm -rf /flarum/.composer /tmp/* \
|
&& rm -rf /flarum/.composer /tmp/* /flarum/app/storage/logs \
|
||||||
|
&& cd /flarum/app/storage/ \
|
||||||
|
&& ln -s /var/log/flarum logs \
|
||||||
&& setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/nginx
|
&& setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/nginx
|
||||||
|
|
||||||
COPY rootfs /
|
COPY rootfs /
|
||||||
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/run /etc/s6.d/.s6-svscan/*
|
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/run /etc/s6.d/.s6-svscan/*
|
||||||
VOLUME /etc/nginx/flarum /flarum/app/extensions /flarum/app/public/assets /flarum/app/storage/logs
|
VOLUME /etc/nginx/flarum /flarum/app/extensions /flarum/app/public/assets /var/log
|
||||||
CMD ["/usr/local/bin/startup"]
|
CMD ["/usr/local/bin/startup"]
|
||||||
|
|
11
README.md
11
README.md
|
@ -34,10 +34,10 @@
|
||||||
|
|
||||||
### Volume
|
### Volume
|
||||||
|
|
||||||
|
- **/etc/nginx/flarum** : Nginx location directory
|
||||||
- **/flarum/app/extensions** : Flarum extension directory
|
- **/flarum/app/extensions** : Flarum extension directory
|
||||||
- **/flarum/app/public/assets** : Flarum assets directory
|
- **/flarum/app/public/assets** : Flarum assets directory
|
||||||
- **/flarum/app/storage/logs** : Flarum logs directory
|
- **/var/log** : Flarum & Nginx & PHP-FPM log directory
|
||||||
- **/etc/nginx/flarum** : Nginx location directory
|
|
||||||
|
|
||||||
### Environment variables
|
### Environment variables
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@
|
||||||
| **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M
|
| **UPLOAD_MAX_SIZE** | The maximum size of an uploaded file | *optional* | 50M
|
||||||
| **PHP_MEMORY_LIMIT** | PHP memory limit | *optional* | 128M |
|
| **PHP_MEMORY_LIMIT** | PHP memory limit | *optional* | 128M |
|
||||||
| **OPCACHE_MEMORY_LIMIT** | OPcache memory size in megabytes | *optional* | 128
|
| **OPCACHE_MEMORY_LIMIT** | OPcache memory size in megabytes | *optional* | 128
|
||||||
| **LOG_TO_STDOUT** | Enable nginx and php error logs to stdout | *optional* | false
|
| **LOG_TO_STDOUT** | Enable nginx and php error logs to stdout (abandoned in the future)| *optional* | false
|
||||||
|
| **LOG_OUTOUT** | Set nginx and php log output (value: file/stdio) | *optional* | file
|
||||||
| **GITHUB_TOKEN_AUTH** | Github token to download private extensions | *optional* | false
|
| **GITHUB_TOKEN_AUTH** | Github token to download private extensions | *optional* | false
|
||||||
| **PHP_EXTENSIONS** | Install additional php extensions | *optional* | none
|
| **PHP_EXTENSIONS** | Install additional php extensions | *optional* | none
|
||||||
|
|
||||||
|
@ -96,7 +97,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/docker/flarum/assets:/flarum/app/public/assets
|
- /mnt/docker/flarum/assets:/flarum/app/public/assets
|
||||||
- /mnt/docker/flarum/extensions:/flarum/app/extensions
|
- /mnt/docker/flarum/extensions:/flarum/app/extensions
|
||||||
- /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
|
- /mnt/docker/flarum/log:/var/log
|
||||||
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
|
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
|
||||||
ports:
|
ports:
|
||||||
- 80:8888
|
- 80:8888
|
||||||
|
@ -170,7 +171,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- /mnt/docker/flarum/assets:/flarum/app/public/assets
|
- /mnt/docker/flarum/assets:/flarum/app/public/assets
|
||||||
- /mnt/docker/flarum/extensions:/flarum/app/extensions
|
- /mnt/docker/flarum/extensions:/flarum/app/extensions
|
||||||
- /mnt/docker/flarum/storage/logs:/flarum/app/storage/logs
|
- /mnt/docker/flarum/log:/var/log
|
||||||
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
|
- /mnt/docker/flarum/nginx:/etc/nginx/flarum
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
worker_processes auto;
|
|
||||||
pid /tmp/nginx.pid;
|
|
||||||
daemon off;
|
daemon off;
|
||||||
|
error_log <path-to-nginx-error_log> warn;
|
||||||
|
pid /tmp/nginx.pid;
|
||||||
|
worker_processes auto;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
|
@ -11,8 +12,7 @@ http {
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
access_log off;
|
access_log <path-to-nginx-access_log>;
|
||||||
error_log /tmp/ngx_error.log error;
|
|
||||||
|
|
||||||
sendfile on;
|
sendfile on;
|
||||||
keepalive_timeout 15;
|
keepalive_timeout 15;
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
|
|
||||||
[global]
|
[global]
|
||||||
daemonize = no
|
daemonize = no
|
||||||
error_log = /tmp/php_error.log
|
error_log = <path-to-php-fpm-error_log>
|
||||||
|
|
||||||
[www]
|
[www]
|
||||||
listen = /run/php/php8-fpm.sock
|
listen = /run/php/php8-fpm.sock
|
||||||
|
access.log = <path-to-php-fpm-access_log>
|
||||||
pm = ondemand
|
pm = ondemand
|
||||||
pm.max_children = 30
|
pm.max_children = 30
|
||||||
pm.process_idle_timeout = 10s
|
pm.process_idle_timeout = 10s
|
||||||
|
|
|
@ -30,14 +30,43 @@ done
|
||||||
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \+
|
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \+
|
||||||
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \+
|
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \+
|
||||||
|
|
||||||
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
|
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true) (abandoned in the future)
|
||||||
|
#echo "[WARN] Environment variables LOG_TO_STDOUT will be abandoned in the future"
|
||||||
if [ "${LOG_TO_STDOUT}" = true ]; then
|
if [ "${LOG_TO_STDOUT}" = true ]; then
|
||||||
echo "[INFO] Logging to stdout activated"
|
echo "[INFO] Logging to stdout activated"
|
||||||
chmod o+w /dev/stdout
|
LOG_OUTPUT='stdio'
|
||||||
sed -i "s/.*error_log.*$/error_log \/dev\/stdout warn;/" /etc/nginx/nginx.conf
|
else
|
||||||
sed -i "s/.*error_log.*$/error_log = \/dev\/stdout/" /etc/php8/php-fpm.d/www.conf
|
LOG_OUTPUT='file'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set log output
|
||||||
|
set_log_to_stdio(){
|
||||||
|
# by https://serverfault.com/questions/658367/how-to-get-php-fpm-to-log-to-stdout-stderr-when-running-in-a-docker-container
|
||||||
|
sed -i 's,<path-to-nginx-access_log>,/proc/self/fd/1,' /etc/nginx/nginx.conf
|
||||||
|
sed -i 's,<path-to-nginx-error_log>,/proc/self/fd/2,' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
sed -i 's,<path-to-php-fpm-access_log>,/proc/self/fd/1,' /etc/php8/php-fpm.d/www.conf
|
||||||
|
sed -i 's,<path-to-php-fpm-error_log>,/proc/self/fd/2,' /etc/php8/php-fpm.d/www.conf
|
||||||
|
|
||||||
|
}
|
||||||
|
chown -R "${UID}":"${GID}" /var/log/*
|
||||||
|
case "${LOG_OUTPUT}" in
|
||||||
|
'file')
|
||||||
|
sed -i 's,<path-to-nginx-access_log>,/var/log/nginx/nginx-access.log,' /etc/nginx/nginx.conf
|
||||||
|
sed -i 's,<path-to-nginx-error_log>,/var/log/nginx/nginx-error.log,' /etc/nginx/nginx.conf
|
||||||
|
|
||||||
|
sed -i 's,<path-to-php-fpm-access_log>,/var/log/php8/fpm-access.log,' /etc/php8/php-fpm.d/www.conf
|
||||||
|
sed -i 's,<path-to-php-fpm-error_log>,/var/log/php8/fpm-error.log,' /etc/php8/php-fpm.d/www.conf
|
||||||
|
;;
|
||||||
|
'stdio')
|
||||||
|
set_log_to_stdio
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "[WARN] The environment variable LOG_OUTPUT has an incorrect value or is not set, use stdio"
|
||||||
|
set_log_to_stdio
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Install additional php extensions
|
# Install additional php extensions
|
||||||
if [ -n "${PHP_EXTENSIONS}" ]; then
|
if [ -n "${PHP_EXTENSIONS}" ]; then
|
||||||
for php_extension in ${PHP_EXTENSIONS}; do
|
for php_extension in ${PHP_EXTENSIONS}; do
|
||||||
|
|
Loading…
Reference in New Issue