Simplify compose database startup
This commit is contained in:
@@ -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
@@ -3,8 +3,8 @@ services:
|
|||||||
build: .
|
build: .
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
db:
|
- db
|
||||||
condition: service_healthy
|
command: sh -c "sleep 25 && apache2-foreground"
|
||||||
environment:
|
environment:
|
||||||
DB_HOST: db
|
DB_HOST: db
|
||||||
DB_PORT: "3306"
|
DB_PORT: "3306"
|
||||||
@@ -28,12 +28,6 @@ services:
|
|||||||
- ./01/spbu_db.sql:/docker-entrypoint-initdb.d/01-spbu_db.sql:ro
|
- ./01/spbu_db.sql:/docker-entrypoint-initdb.d/01-spbu_db.sql:ro
|
||||||
- ./02/webgis2.sql:/docker-entrypoint-initdb.d/02-webgis2.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
|
- ./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:
|
volumes:
|
||||||
webgis_db_data:
|
webgis_db_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user