diff --git a/.env b/.env index 04b50a5b90..1983bf8287 100644 --- a/.env +++ b/.env @@ -305,9 +305,15 @@ REQUEST_TERMINATE_TIMEOUT=300s # Maximum amount of memory a script may consume (128MB) # http://php.net/memory-limit +# @run FPM_MEMORY_LIMIT=2048M PHP_CLI_MEMORY_LIMIT=2048M +# Temporary directory for HTTP uploaded files (will use system default if not +# specified). +# http://php.net/upload-tmp-dir +# @run +PHP_UPLOAD_TMP_DIR=/var/alchemy/Phraseanet/tmp/php_upload_tmp # Php Opcache status. See [opcache Php documentation| # https://www.php.net/manual/en/intro.opcache.php]. diff --git a/docker-compose.yml b/docker-compose.yml index e5914218fe..b378c472f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -105,6 +105,7 @@ services: - SESSION_CACHE_LIMITER - PHP_LOG_LEVEL - PHP_CLI_MEMORY_LIMIT + - PHP_UPLOAD_TMP_DIR - PHRASEANET_ADMIN_ACCOUNT_ID - PHRASEANET_ADMIN_ACCOUNT_EMAIL - PHRASEANET_ADMIN_ACCOUNT_PASSWORD @@ -230,6 +231,7 @@ services: - OPCACHE_ENABLED - SESSION_CACHE_LIMITER - PHP_LOG_LEVEL + - PHP_UPLOAD_TMP_DIR - PHRASEANET_SCHEME - PHRASEANET_HOSTNAME - PHRASEANET_APP_PORT diff --git a/docker/phraseanet/fpm/entrypoint.sh b/docker/phraseanet/fpm/entrypoint.sh index b14b8f917f..98caf8a08c 100755 --- a/docker/phraseanet/fpm/entrypoint.sh +++ b/docker/phraseanet/fpm/entrypoint.sh @@ -5,7 +5,6 @@ set -e envsubst < "docker/phraseanet/php.ini.sample" > /usr/local/etc/php/php.ini envsubst < "docker/phraseanet/php-fpm.conf.sample" > /usr/local/etc/php-fpm.conf envsubst < "docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf" > /usr/local/etc/php-fpm.d/zz-docker.conf -# cat docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf | sed "s/\$REQUEST_TERMINATE_TIMEOUT/$REQUEST_TERMINATE_TIMEOUT/g" > /usr/local/etc/php-fpm.d/zz-docker.conf if [ ${XDEBUG_ENABLED} == "1" ]; then echo "XDEBUG is enabled. YOU MAY KEEP THIS FEATURE DISABLED IN PRODUCTION." @@ -35,12 +34,6 @@ fi chown -R app:app cache echo `date +"%Y-%m-%d %H:%M:%S"` " - chown APP:APP on cache/ repository" -# config \ -# tmp \ -# logs \ -# www - - if [ -d "plugins/" ];then chown -R app:app plugins echo `date +"%Y-%m-%d %H:%M:%S"` " - chown APP:APP on plugins/ repository" diff --git a/docker/phraseanet/php.ini.sample b/docker/phraseanet/php.ini.sample index a4c714dc60..c738feb74f 100644 --- a/docker/phraseanet/php.ini.sample +++ b/docker/phraseanet/php.ini.sample @@ -817,7 +817,7 @@ file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ; http://php.net/upload-tmp-dir -;upload_tmp_dir = +upload_tmp_dir = $PHP_UPLOAD_TMP_DIR ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize diff --git a/docker/phraseanet/setup/entrypoint.sh b/docker/phraseanet/setup/entrypoint.sh index 8abaad59c7..02d1ca4aa2 100755 --- a/docker/phraseanet/setup/entrypoint.sh +++ b/docker/phraseanet/setup/entrypoint.sh @@ -4,6 +4,20 @@ set -e envsubst < "docker/phraseanet/php.ini.worker.sample" > /usr/local/etc/php/php.ini cat docker/phraseanet/root/usr/local/etc/php-fpm.d/zz-docker.conf | sed "s/\$REQUEST_TERMINATE_TIMEOUT/$REQUEST_TERMINATE_TIMEOUT/g" > /usr/local/etc/php-fpm.d/zz-docker.conf +if [ -d "$PHP_UPLOAD_TMP_DIR" ]; then + echo `date +"%Y-%m-%d %H:%M:%S"` " - The directory: $PHP_UPLOAD_TMP_DIR already exists." +else + echo `date +"%Y-%m-%d %H:%M:%S"` " - The directory: $PHP_UPLOAD_TMP_DIR does not exist. Creating the directory..." + mkdir -p "$PHP_UPLOAD_TMP_DIR" + + if [ $? -eq 0 ]; then + echo `date +"%Y-%m-%d %H:%M:%S"` " - The directory: $PHP_UPLOAD_TMP_DIR was successfully created." + else + echo `date +"%Y-%m-%d %H:%M:%S"` " - Failed to create directory: $PHP_UPLOAD_TMP_DIR." + exit 1 + fi +fi + if [[ -z "$PHRASEANET_APP_PORT" || $PHRASEANET_APP_PORT = "80" || $PHRASEANET_APP_PORT = "443" ]];then export PHRASEANET_BASE_URL="$PHRASEANET_SCHEME://$PHRASEANET_HOSTNAME" echo `date +"%Y-%m-%d %H:%M:%S"` " - Phraseanet BASE URL IS : " $PHRASEANET_BASE_URL @@ -293,9 +307,14 @@ chown -R app:app backup echo `date +"%Y-%m-%d %H:%M:%S"` " - chown APP:APP on www/repository excluding www/thumbnails" cd www chown -R app:app $(ls -I thumbnails) - + echo `date +"%Y-%m-%d %H:%M:%S"` " - End of chown!" +if [ -d "$PHP_UPLOAD_TMP_DIR" ]; then + echo `date +"%Y-%m-%d %H:%M:%S"` " - Cleaning files older than 2 days in $PHP_UPLOAD_TMP_DIR " + find "$PHP_UPLOAD_TMP_DIR" -type f -mtime +2 -exec rm -f {} \; +fi + echo `date +"%Y-%m-%d %H:%M:%S"` " - End of Phraseanet setup entrypoint.sh"