diff --git a/.dockerignore b/.dockerignore index 068d6cc396..5b7d380142 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 + + diff --git a/.env b/.env index 39ec089b92..ae96d23fdd 100644 --- a/.env +++ b/.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="

Under maintenance!

More information here

" # @run -PHRASEANET_MAINTENANCE_MESSAGE= +PHRASEANET_MAINTENANCE_MESSAGE="Site: $PHRASEANET_PROJECT_NAME are under Maintenance ! Sorry, come back Later" # --- RabbitMQ settings ------------------------------------------------------------------------------------------------ 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 5d511fa7f0..ff8b33ccdf 100644 --- a/docker-compose.alternatives.yml +++ b/docker-compose.alternatives.yml @@ -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' diff --git a/docker-compose.datastores.yml b/docker-compose.datastores.yml index 187cb7040b..a1fa2e01d6 100644 --- a/docker-compose.datastores.yml +++ b/docker-compose.datastores.yml @@ -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"] 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..4e9f1b48d3 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-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