Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHRAS-4100 Php upload tmp directory #4553

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -230,6 +231,7 @@ services:
- OPCACHE_ENABLED
- SESSION_CACHE_LIMITER
- PHP_LOG_LEVEL
- PHP_UPLOAD_TMP_DIR
- PHRASEANET_SCHEME
- PHRASEANET_HOSTNAME
- PHRASEANET_APP_PORT
Expand Down
7 changes: 0 additions & 7 deletions docker/phraseanet/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion docker/phraseanet/php.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion docker/phraseanet/setup/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"


Expand Down
Loading