feat: add .env support for coolify deployment
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
APP_NAME="WebGIS Sebaran Penduduk Miskin"
|
||||
BASE_URL="https://your-coolify-domain.com"
|
||||
|
||||
# Database Configuration
|
||||
DB_HOST=127.0.0.1
|
||||
DB_USER=root
|
||||
DB_PASS=secret
|
||||
DB_NAME=poverty_map
|
||||
@@ -0,0 +1,4 @@
|
||||
.env
|
||||
.DS_Store
|
||||
/assets/uploads/*
|
||||
!/assets/uploads/index.html
|
||||
+19
-1
@@ -3,8 +3,26 @@
|
||||
// Konfigurasi Global Aplikasi
|
||||
// ================================================================
|
||||
|
||||
// Simple .env parser (for local use)
|
||||
$envFile = __DIR__ . '/../.env';
|
||||
if (file_exists($envFile)) {
|
||||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), '#') === 0) continue;
|
||||
list($name, $value) = explode('=', $line, 2);
|
||||
$name = trim($name);
|
||||
$value = trim($value, " \t\n\r\0\x0B\"'"); // Strip whitespace and quotes
|
||||
if (!array_key_exists($name, $_SERVER) && !array_key_exists($name, $_ENV)) {
|
||||
putenv(sprintf('%s=%s', $name, $value));
|
||||
$_ENV[$name] = $value;
|
||||
$_SERVER[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Base URL aplikasi
|
||||
define('BASE_URL', 'http://localhost/webjir/poverty_map');
|
||||
$defaultBaseUrl = 'http://localhost/webjir/poverty_map';
|
||||
define('BASE_URL', getenv('BASE_URL') ?: $defaultBaseUrl);
|
||||
define('BASE_PATH', dirname(__DIR__));
|
||||
|
||||
// Koordinat default peta (Pontianak)
|
||||
|
||||
+4
-4
@@ -2,10 +2,10 @@
|
||||
// ================================================================
|
||||
// Konfigurasi Database
|
||||
// ================================================================
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_USER', 'root');
|
||||
define('DB_PASS', '');
|
||||
define('DB_NAME', 'poverty_map');
|
||||
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
|
||||
define('DB_USER', getenv('DB_USER') ?: 'root');
|
||||
define('DB_PASS', getenv('DB_PASS') !== false ? getenv('DB_PASS') : '');
|
||||
define('DB_NAME', getenv('DB_NAME') ?: 'poverty_map');
|
||||
define('DB_CHARSET','utf8mb4');
|
||||
|
||||
function getDB(): PDO {
|
||||
|
||||
Reference in New Issue
Block a user