Simplify compose database startup

This commit is contained in:
2026-06-11 13:39:50 +07:00
parent ab46769df1
commit bfd6b1d8cf
2 changed files with 17 additions and 8 deletions
+15
View File
@@ -0,0 +1,15 @@
<?php
header('Content-Type: application/json');
include 'koneksi.php';
$result = $conn->query("SELECT DATABASE() AS db_name, NOW() AS server_time");
$row = $result ? $result->fetch_assoc() : null;
echo json_encode([
"status" => "success",
"db" => $row["db_name"] ?? null,
"server_time" => $row["server_time"] ?? null,
"host_env" => getenv("DB_HOST") ?: null,
"port_env" => getenv("DB_PORT") ?: null,
"user_env" => getenv("DB_USER") ?: null,
]);
+2 -8
View File
@@ -3,8 +3,8 @@ services:
build: .
restart: unless-stopped
depends_on:
db:
condition: service_healthy
- db
command: sh -c "sleep 25 && apache2-foreground"
environment:
DB_HOST: db
DB_PORT: "3306"
@@ -28,12 +28,6 @@ services:
- ./01/spbu_db.sql:/docker-entrypoint-initdb.d/01-spbu_db.sql:ro
- ./02/webgis2.sql:/docker-entrypoint-initdb.d/02-webgis2.sql:ro
- ./05/webgis_uas.sql:/docker-entrypoint-initdb.d/05-webgis_uas.sql:ro
healthcheck:
test: ["CMD-SHELL", "mariadb-admin ping -h 127.0.0.1 -uroot -p$${MARIADB_ROOT_PASSWORD} --silent"]
interval: 10s
timeout: 5s
retries: 15
start_period: 30s
volumes:
webgis_db_data: