-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrunEnv
More file actions
executable file
·49 lines (43 loc) · 1.58 KB
/
Copy pathrunEnv
File metadata and controls
executable file
·49 lines (43 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Shell interattiva per compilare/lanciare myst con MySQL + Adminer in Docker.
# Su Mac ARM64 forza linux/amd64 (mudcompiler non ha manifest arm64).
trap cleanup INT TERM EXIT
set -e
export DOCKER_PLATFORM=linux/amd64
export LOCAL_UID=$(id -u)
export LOCAL_GID=$(id -g)
# docker compose legge .env per ${LOCAL_UID}/${LOCAL_GID} su mysql e consumer.
printf 'LOCAL_UID=%s\nLOCAL_GID=%s\nDOCKER_PLATFORM=%s\n' \
"$LOCAL_UID" "$LOCAL_GID" "$DOCKER_PLATFORM" > .env
if command -v docker-compose >/dev/null 2>&1; then
compose='docker-compose'
else
compose='docker compose'
fi
cleanup() {
$compose down
}
# mysql_data deve essere scrivibile dall'uid del consumer/mysql.
if [ ! -d mysql_data ]; then
mkdir -p mysql_data
fi
mysql_owner=$(stat -c %u mysql_data 2>/dev/null || stat -f %u mysql_data 2>/dev/null)
if [ "$mysql_owner" != "$LOCAL_UID" ]; then
echo "⚠️ mysql_data owned by uid $mysql_owner (expected $LOCAL_UID)."
if chown -R "$LOCAL_UID:$LOCAL_GID" mysql_data 2>/dev/null; then
echo " Fixed ownership of mysql_data."
else
echo " Run once: sudo chown -R $LOCAL_UID:$LOCAL_GID mysql_data"
fi
fi
# rimuove la cartella build se l'owner è root
if [ -d build ]; then
owner=$(stat -c %U build 2>/dev/null || stat -f %Su build 2>/dev/null)
if [ "$owner" = "root" ]; then
echo "⚠️ La cartella 'build' è di proprietà di root, la rimuovo."
$compose run --rm --no-deps --name consumer-rm --entrypoint=/usr/bin/rm consumer -rf build
echo "⚠️ La cartella 'build' è stata rimossa."
fi
fi
docker-compose pull
$compose run --rm -it --service-ports --name mudcompiler mudcompiler