-
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
51 lines (41 loc) · 1.64 KB
/
Copy pathdocker-entrypoint.sh
File metadata and controls
51 lines (41 loc) · 1.64 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
50
51
#!/bin/bash
set -e
APP_DIR="/app/eBot-CSGO-Web"
SOURCE_DIR="/app/source"
# Copy source to volume target if not already present
if [ ! -f "$APP_DIR/symfony" ]; then
echo "[entrypoint] Copying source files to $APP_DIR..."
cp -r "$SOURCE_DIR/." "$APP_DIR/"
fi
cd "$APP_DIR"
# Remove installation wizard (safe on every start)
rm -rf web/installation
# Wait for MySQL to be ready
MYSQL_HOST="${MYSQL_HOST:-mysqldb}"
echo "[entrypoint] Waiting for MySQL at $MYSQL_HOST..."
until mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" -e "SELECT 1" > /dev/null 2>&1; do
echo "[entrypoint] MySQL not ready yet, retrying in 3s..."
sleep 3
done
echo "[entrypoint] MySQL is ready."
# Check if schema already exists by probing sf_guard_user table
TABLE_EXISTS=$(mysql -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" \
-e "SHOW TABLES LIKE 'sf_guard_user';" 2>/dev/null | grep -c "sf_guard_user" || true)
if [ "$TABLE_EXISTS" -eq 0 ]; then
echo "[entrypoint] Schema not found — building database..."
php symfony doctrine:build --all --no-confirmation
echo "[entrypoint] Creating admin user..."
php symfony guard:create-user --is-super-admin \
"$EBOT_ADMIN_EMAIL" \
"$EBOT_ADMIN_LOGIN" \
"$EBOT_ADMIN_PASSWORD" \
"${EBOT_ADMIN_FIRSTNAME:-}" \
"${EBOT_ADMIN_LASTNAME:-}"
else
echo "[entrypoint] Schema already exists — skipping doctrine:build."
fi
# Clear Symfony cache (always safe)
echo "[entrypoint] Clearing Symfony cache..."
php symfony cc
echo "[entrypoint] Starting php-fpm..."
exec php-fpm