stack management WIP

This commit is contained in:
nmaillat
2025-05-26 17:39:32 +02:00
parent 36dd637256
commit 8b95b46ed0
6 changed files with 55 additions and 8 deletions

View File

@@ -8,6 +8,7 @@
/env.* /env.*
/.git /.git
/.gitignore /.gitignore
/.github
/.travis.yml /.travis.yml
/AUTHORS /AUTHORS
/CONTRIBUTORS /CONTRIBUTORS
@@ -40,4 +41,6 @@
npm-debug.log npm-debug.log
stack.sh stack.sh
/.vagrant /.vagrant
/Vagrantfile

View File

@@ -97,8 +97,8 @@ Get official support : https://www.alchemy.fr/en/rubrique/services/
## Prerequisites ## Prerequisites
- docker >=25.0.5 - docker >=27.3.1
- docker compose >= 2.29.0 - docker compose >= 2.30.3
In the stack Docker, Docker Compose included in this repo starts by default in test mode. 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, All services are launched in a separate container and except "Phraseanet app" and "workers" containers,

View File

@@ -29,5 +29,6 @@ services:
internal: internal:
aliases: aliases:
- db - db
pre_stop:
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'

View File

@@ -22,6 +22,8 @@ services:
internal: internal:
aliases: aliases:
- db - db
pre_stop:
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
db-docker-vol: db-docker-vol:
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-db:$PHRASEANET_DOCKER_TAG image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-db:$PHRASEANET_DOCKER_TAG
@@ -46,7 +48,8 @@ services:
internal: internal:
aliases: aliases:
- db - db
pre_stop:
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
rabbitmq: rabbitmq:
image: $RABBITMQ_IMAGE_TAG image: $RABBITMQ_IMAGE_TAG
profiles: ["rabbitmq"] profiles: ["rabbitmq"]

View File

@@ -271,6 +271,7 @@ services:
- SESSION_SAVE_HANDLER - SESSION_SAVE_HANDLER
- SESSION_SAVE_PATH - SESSION_SAVE_PATH
- PHRASEANET_MAINTENANCE - PHRASEANET_MAINTENANCE
- PHRASEANET_MAINTENANCE_MESSAGE
- FPM_MEMORY_LIMIT - FPM_MEMORY_LIMIT
- FPM_PM_TYPE - FPM_PM_TYPE
- FPM_MAXCHILDREN - FPM_MAXCHILDREN

View File

@@ -37,6 +37,7 @@ stack_status() {
display_rabbitmq_info display_rabbitmq_info
echo echo
display_db_info display_db_info
} }
@@ -191,8 +192,8 @@ check_compose_version() {
echo "Docker Compose v1 detected." echo "Docker Compose v1 detected."
fi fi
local required_docker_version="25.0.5" local required_docker_version="27.3.1"
local required_compose_version="2.29.0" local required_compose_version="2.30.3"
# Get Docker version # Get Docker version
local docker_version=$(docker --version | awk -F'[ ,]' '{print $3}') 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;"' $DOCKER_COMPOSE_CMD exec db sh -c 'env |grep MYSQL_ & mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "SHOW DATABASES;SHOW PROCESSLIST;"'
echo 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 # Check the argument passed to the script
case "$1" in case "$1" in
start) start)
@@ -238,8 +266,19 @@ case "$1" in
logs) logs)
display_logs "$2" 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 exit 1
esac esac