mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-07 01:54:27 +00:00
PHRAS-4149 stack management (#4615)
* docker compose files reorganisation * stack management WIP * rename function
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
/env.*
|
||||
/.git
|
||||
/.gitignore
|
||||
/.github
|
||||
/.travis.yml
|
||||
/AUTHORS
|
||||
/CONTRIBUTORS
|
||||
@@ -38,4 +39,8 @@
|
||||
/www/thumbnails
|
||||
/www/.htaccess
|
||||
npm-debug.log
|
||||
stack_management.sh
|
||||
stack.sh
|
||||
/.vagrant
|
||||
/Vagrantfile
|
||||
|
||||
|
||||
|
5
.env
5
.env
@@ -60,8 +60,9 @@
|
||||
# choose to launch only some workers, see worker profile list below.
|
||||
# - "worker" : launch one container worker with all jobs run on it.
|
||||
# - "cmd" : launch a container based on worker image, useful for run cmd manualy.
|
||||
# - "db" : db profile will launch a mariadb container,
|
||||
# - "db" : db profile will launch a mariadb container, with data stored on host and mounted in the db container.
|
||||
# because this is the primary datastore, you should use you own SGDD service for production needs.
|
||||
# - "db-docker-vol" : same as "db" profile but with data stored in a docker volume.
|
||||
# - "elastisearch" : launch a elasticsearch container.
|
||||
# - "rabbitmq" : launch a rabbitmq container.
|
||||
# - "redis" : launch a redis container for app cache.
|
||||
@@ -257,7 +258,7 @@ PHRASEANET_MAINTENANCE=0
|
||||
# Example :
|
||||
# PHRASEANET_MAINTENANCE_MESSAGE="<p>Under maintenance!</p><p>More information <a href=\"https://www.yoururl.fr\">here</a></p>"
|
||||
# @run
|
||||
PHRASEANET_MAINTENANCE_MESSAGE=
|
||||
PHRASEANET_MAINTENANCE_MESSAGE="Site: $PHRASEANET_PROJECT_NAME are under Maintenance ! Sorry, come back Later"
|
||||
|
||||
# --- RabbitMQ settings ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -1,26 +1,4 @@
|
||||
services:
|
||||
|
||||
db:
|
||||
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-db:$PHRASEANET_DOCKER_TAG
|
||||
build: ./docker/db
|
||||
restart: on-failure
|
||||
profiles: ["db-volume-container"]
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
- MYSQL_MAX_ALLOWED_PACKET
|
||||
- MYSQL_MAX_CONNECTION
|
||||
- MYSQL_LONG_QUERY_TIME
|
||||
- MYSQL_SLOW_QUERY_LOG
|
||||
- MYSQL_QUERY_CACHE_LIMIT
|
||||
- MYSQL_QUERY_CACHE_SIZE
|
||||
- MYSQL_KEY_BUFFER_SIZE
|
||||
- MYSQL_CONNECT_TIMEOUT
|
||||
- MYSQL_WAIT_TIMEOUT
|
||||
- MARIADB_AUTO_UPGRADE
|
||||
volumes:
|
||||
- db_vol:/var/lib/mysql
|
||||
networks:
|
||||
- internal
|
||||
db-mysql8:
|
||||
image: mysql:8.0.36-debian
|
||||
# NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
|
||||
@@ -51,4 +29,6 @@ services:
|
||||
internal:
|
||||
aliases:
|
||||
- db
|
||||
pre_stop:
|
||||
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
|
||||
|
||||
|
@@ -19,8 +19,37 @@ services:
|
||||
volumes:
|
||||
- ${PHRASEANET_DB_DIR}:/var/lib/mysql
|
||||
networks:
|
||||
- internal
|
||||
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
|
||||
build: ./docker/db
|
||||
restart: on-failure
|
||||
profiles: ["db-docker-vol"]
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
- MYSQL_MAX_ALLOWED_PACKET
|
||||
- MYSQL_MAX_CONNECTION
|
||||
- MYSQL_LONG_QUERY_TIME
|
||||
- MYSQL_SLOW_QUERY_LOG
|
||||
- MYSQL_QUERY_CACHE_LIMIT
|
||||
- MYSQL_QUERY_CACHE_SIZE
|
||||
- MYSQL_KEY_BUFFER_SIZE
|
||||
- MYSQL_CONNECT_TIMEOUT
|
||||
- MYSQL_WAIT_TIMEOUT
|
||||
- MARIADB_AUTO_UPGRADE
|
||||
volumes:
|
||||
- db_vol:/var/lib/mysql
|
||||
networks:
|
||||
internal:
|
||||
aliases:
|
||||
- db
|
||||
pre_stop:
|
||||
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
|
||||
rabbitmq:
|
||||
image: $RABBITMQ_IMAGE_TAG
|
||||
profiles: ["rabbitmq"]
|
||||
|
@@ -271,6 +271,7 @@ services:
|
||||
- SESSION_SAVE_HANDLER
|
||||
- SESSION_SAVE_PATH
|
||||
- PHRASEANET_MAINTENANCE
|
||||
- PHRASEANET_MAINTENANCE_MESSAGE
|
||||
- FPM_MEMORY_LIMIT
|
||||
- FPM_PM_TYPE
|
||||
- FPM_MAXCHILDREN
|
||||
|
47
stack.sh
47
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-setup)
|
||||
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]|apply-setup}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
Reference in New Issue
Block a user