diff --git a/.dockerignore b/.dockerignore index f8921815df..5b7d380142 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,7 @@ /env.* /.git /.gitignore +/.github /.travis.yml /AUTHORS /CONTRIBUTORS @@ -40,4 +41,6 @@ npm-debug.log stack.sh /.vagrant +/Vagrantfile + diff --git a/README.md b/README.md index dae1d7cc23..c75c521673 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ Get official support : https://www.alchemy.fr/en/rubrique/services/ ## Prerequisites -- docker >=25.0.5 -- docker compose >= 2.29.0 +- docker >=27.3.1 +- docker compose >= 2.30.3 In the stack Docker, Docker Compose included in this repo starts by default in test mode. All services are launched in a separate container and except "Phraseanet app" and "workers" containers, diff --git a/docker-compose.alternatives.yml b/docker-compose.alternatives.yml index 6363c05906..ff8b33ccdf 100644 --- a/docker-compose.alternatives.yml +++ b/docker-compose.alternatives.yml @@ -29,5 +29,6 @@ services: internal: aliases: - db - + pre_stop: + - command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown' diff --git a/docker-compose.datastores.yml b/docker-compose.datastores.yml index 373e291681..a1fa2e01d6 100644 --- a/docker-compose.datastores.yml +++ b/docker-compose.datastores.yml @@ -22,6 +22,8 @@ services: internal: aliases: - db + pre_stop: + - command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown' db-docker-vol: image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-db:$PHRASEANET_DOCKER_TAG @@ -46,7 +48,8 @@ services: internal: aliases: - db - + pre_stop: + - command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown' rabbitmq: image: $RABBITMQ_IMAGE_TAG profiles: ["rabbitmq"] diff --git a/docker-compose.yml b/docker-compose.yml index 355cc5eedc..d480be39ab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -271,6 +271,7 @@ services: - SESSION_SAVE_HANDLER - SESSION_SAVE_PATH - PHRASEANET_MAINTENANCE + - PHRASEANET_MAINTENANCE_MESSAGE - FPM_MEMORY_LIMIT - FPM_PM_TYPE - FPM_MAXCHILDREN diff --git a/stack.sh b/stack.sh index 1d03847681..fc8c59ab79 100755 --- a/stack.sh +++ b/stack.sh @@ -37,6 +37,7 @@ stack_status() { display_rabbitmq_info echo + display_db_info } @@ -191,8 +192,8 @@ check_compose_version() { echo "Docker Compose v1 detected." fi - local required_docker_version="25.0.5" - local required_compose_version="2.29.0" + local required_docker_version="27.3.1" + local required_compose_version="2.30.3" # Get Docker version local docker_version=$(docker --version | awk -F'[ ,]' '{print $3}') @@ -220,7 +221,34 @@ display_db_info () { $DOCKER_COMPOSE_CMD exec db sh -c 'env |grep MYSQL_ & mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "SHOW DATABASES;SHOW PROCESSLIST;"' echo } - + # Function to enable or disable maintenance mode +maintenance_mode() { + if [ "$1" == "on" ]; then + echo "Enabling maintenance mode..." + $DOCKER_COMPOSE_CMD exec phraseanet sh -c 'envsubst < "/usr/local/etc/maintenance.html" > /var/alchemy/Phraseanet/datas/nginx/maintenance.html' + echo "Maintenance mode is now enabled. it will be disabling after the next restart of stack." + echo "if you want persist maintenance mode, you must set the environment variable PHRASEANET_MAINTENANCE_MODE=1 in your .env file." + elif [ "$1" == "off" ]; then + echo "Disabling maintenance mode..." + $DOCKER_COMPOSE_CMD exec phraseanet sh -c 'rm -rf /var/alchemy/Phraseanet/datas/nginx/maintenance.html' + echo "Maintenance mode is now disabled." + else + echo "Usage: $0 maintenance {on|off}" + exit 1 + fi +} +# Function to apply setup +apply_setup() { + echo "Applying setup..." + local env_files=($(get_env_files)) + $DOCKER_COMPOSE_CMD "${env_files[@]/#/--env-file=}" run --rm setup + if [ $? -eq 0 ]; then + echo "Setup applied successfully." + else + echo "Failed to apply setup." + exit 1 + fi +} # Check the argument passed to the script case "$1" in start) @@ -238,8 +266,19 @@ case "$1" in logs) display_logs "$2" ;; + maintenance) + if [ -n "$2" ]; then + maintenance_mode "$2" + else + echo "Usage: $0 maintenance {on|off}" + exit 1 + fi + ;; + apply) + apply_setup + ;; *) - echo "Usage: $0 {start|stop|status|version|logs [container_name]}" + echo "Usage: $0 {start|stop|status|version|maintenance [on|off]|logs [container_name]}" exit 1 esac