-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-local.sh
More file actions
executable file
·36 lines (29 loc) · 1.03 KB
/
Copy pathrun-local.sh
File metadata and controls
executable file
·36 lines (29 loc) · 1.03 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
#!/bin/bash
wait_for_mysql() {
until docker exec -i mysql mysql -u "$DB_USERNAME" -p"$DB_PASSWORD" -e "SELECT 1" > /dev/null 2>&1; do
echo "Waiting for MySQL to start..."
sleep 10
done
}
# Set default values if variables are not set
DB_USERNAME=${DB_USERNAME:-financialbudgetuser}
DB_PASSWORD=${DB_PASSWORD:-cadI1fzFK3t#El%I}
DB_DATABASE=${DB_DATABASE:-financialbudgetdb}
# Start Docker containers
docker compose --profile dependents up -d
# Check if MySQL container is running
container_status=$(docker inspect -f '{{.State.Running}}' mysql)
if [ "$container_status" != "true" ]; then
echo "MySQL container is not running. Check the container name and startup logs."
exit 1
fi
# Wait for MySQL to be ready
wait_for_mysql
# Execute SQL inserts with UTF-8 charset
docker exec -i mysql mysql -u "$DB_USERNAME" -p"$DB_PASSWORD" "$DB_DATABASE" --default-character-set=utf8mb4 < local/database/insert.sql
if [ $? -eq 0 ]; then
echo "Inserts executed successfully."
else
echo "Error executing inserts in the database." >&2
exit 1
fi