Files
UAS_WEBGIS_MaghfiraIzzati_D…/docker-entrypoint.sh
T

30 lines
1.1 KiB
Bash

#!/bin/bash
set -e
echo "=== Starting WebGIS Application ==="
# Tunggu MySQL siap
echo "Waiting for MySQL at $DB_HOST..."
until mysql -h"$DB_HOST" -uroot -p"$DB_PASS" -e "SELECT 1" > /dev/null 2>&1; do
echo "MySQL not ready yet, retrying in 3s..."
sleep 3
done
echo "MySQL is ready!"
# Setup database webgis (sudah ada CREATE DATABASE di dalam file SQL)
echo "Setting up webgis database..."
mysql -h"$DB_HOST" -uroot -p"$DB_PASS" < /var/www/html/WEBGIS/01/api/setup_webgis.sql && echo "webgis OK!" || echo "webgis already exists, skipping."
# Buat database kemiskinan_ibadah jika belum ada
echo "Creating kemiskinan_ibadah database..."
mysql -h"$DB_HOST" -uroot -p"$DB_PASS" -e "CREATE DATABASE IF NOT EXISTS kemiskinan_ibadah CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
# Import tabel ke kemiskinan_ibadah
echo "Importing kemiskinan_ibadah tables..."
mysql -h"$DB_HOST" -uroot -p"$DB_PASS" kemiskinan_ibadah < /var/www/html/webtugas/01/api/setup_webtugas.sql && echo "kemiskinan_ibadah OK!" || echo "kemiskinan_ibadah import done (may already exist)."
echo "=== Database setup complete, starting Apache ==="
# Jalankan Apache
exec apache2-foreground