Skip to content

Commit 26cd156

Browse files
committed
stack management WIP
1 parent da54476 commit 26cd156

File tree

6 files changed

+55
-8
lines changed

6 files changed

+55
-8
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/env.*
99
/.git
1010
/.gitignore
11+
/.github
1112
/.travis.yml
1213
/AUTHORS
1314
/CONTRIBUTORS
@@ -40,4 +41,6 @@
4041
npm-debug.log
4142
stack.sh
4243
/.vagrant
44+
/Vagrantfile
45+
4346

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ Get official support : https://www.alchemy.fr/en/rubrique/services/
9797
## Prerequisites
9898

9999

100-
- docker >=25.0.5
101-
- docker compose >= 2.29.0
100+
- docker >=27.3.1
101+
- docker compose >= 2.30.3
102102

103103
In the stack Docker, Docker Compose included in this repo starts by default in test mode.
104104
All services are launched in a separate container and except "Phraseanet app" and "workers" containers,

docker-compose.alternatives.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ services:
2929
internal:
3030
aliases:
3131
- db
32-
32+
pre_stop:
33+
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
3334

docker-compose.datastores.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ services:
2222
internal:
2323
aliases:
2424
- db
25+
pre_stop:
26+
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
2527

2628
db-docker-vol:
2729
image: $PHRASEANET_DOCKER_REGISTRY/phraseanet-db:$PHRASEANET_DOCKER_TAG
@@ -46,7 +48,8 @@ services:
4648
internal:
4749
aliases:
4850
- db
49-
51+
pre_stop:
52+
- command: '/usr/bin/mysqladmin -uroot -p"$MYSQL_ROOT_PASSWORD" shutdown'
5053
rabbitmq:
5154
image: $RABBITMQ_IMAGE_TAG
5255
profiles: ["rabbitmq"]

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ services:
271271
- SESSION_SAVE_HANDLER
272272
- SESSION_SAVE_PATH
273273
- PHRASEANET_MAINTENANCE
274+
- PHRASEANET_MAINTENANCE_MESSAGE
274275
- FPM_MEMORY_LIMIT
275276
- FPM_PM_TYPE
276277
- FPM_MAXCHILDREN

stack.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ stack_status() {
3737

3838
display_rabbitmq_info
3939
echo
40+
4041
display_db_info
4142
}
4243

@@ -191,8 +192,8 @@ check_compose_version() {
191192
echo "Docker Compose v1 detected."
192193
fi
193194

194-
local required_docker_version="25.0.5"
195-
local required_compose_version="2.29.0"
195+
local required_docker_version="27.3.1"
196+
local required_compose_version="2.30.3"
196197

197198
# Get Docker version
198199
local docker_version=$(docker --version | awk -F'[ ,]' '{print $3}')
@@ -220,7 +221,34 @@ display_db_info () {
220221
$DOCKER_COMPOSE_CMD exec db sh -c 'env |grep MYSQL_ & mysql -uroot -p"$MYSQL_ROOT_PASSWORD" -e "SHOW DATABASES;SHOW PROCESSLIST;"'
221222
echo
222223
}
223-
224+
# Function to enable or disable maintenance mode
225+
maintenance_mode() {
226+
if [ "$1" == "on" ]; then
227+
echo "Enabling maintenance mode..."
228+
$DOCKER_COMPOSE_CMD exec phraseanet sh -c 'envsubst < "/usr/local/etc/maintenance.html" > /var/alchemy/Phraseanet/datas/nginx/maintenance.html'
229+
echo "Maintenance mode is now enabled. it will be disabling after the next restart of stack."
230+
echo "if you want persist maintenance mode, you must set the environment variable PHRASEANET_MAINTENANCE_MODE=1 in your .env file."
231+
elif [ "$1" == "off" ]; then
232+
echo "Disabling maintenance mode..."
233+
$DOCKER_COMPOSE_CMD exec phraseanet sh -c 'rm -rf /var/alchemy/Phraseanet/datas/nginx/maintenance.html'
234+
echo "Maintenance mode is now disabled."
235+
else
236+
echo "Usage: $0 maintenance {on|off}"
237+
exit 1
238+
fi
239+
}
240+
# Function to apply setup
241+
apply_setup() {
242+
echo "Applying setup..."
243+
local env_files=($(get_env_files))
244+
$DOCKER_COMPOSE_CMD "${env_files[@]/#/--env-file=}" run --rm setup
245+
if [ $? -eq 0 ]; then
246+
echo "Setup applied successfully."
247+
else
248+
echo "Failed to apply setup."
249+
exit 1
250+
fi
251+
}
224252
# Check the argument passed to the script
225253
case "$1" in
226254
start)
@@ -238,8 +266,19 @@ case "$1" in
238266
logs)
239267
display_logs "$2"
240268
;;
269+
maintenance)
270+
if [ -n "$2" ]; then
271+
maintenance_mode "$2"
272+
else
273+
echo "Usage: $0 maintenance {on|off}"
274+
exit 1
275+
fi
276+
;;
277+
apply)
278+
apply_setup
279+
;;
241280
*)
242-
echo "Usage: $0 {start|stop|status|version|logs [container_name]}"
281+
echo "Usage: $0 {start|stop|status|version|maintenance [on|off]|logs [container_name]}"
243282
exit 1
244283
esac
245284

0 commit comments

Comments
 (0)