Compare commits

...

5 Commits

Author SHA1 Message Date
Araya's Project 180fe3917f Adding Dockerfile 2026-06-11 19:03:26 +07:00
Araya's Project 5854103517 undockerize project 2026-06-11 17:33:47 +07:00
Araya's Project 2c2636cf45 Credential for db connection 2026-06-11 15:15:01 +07:00
Araya's Project 5b316b2ef6 new configs for deployment 2026-06-11 00:12:43 +07:00
Araya's Project bc415cd947 New config for docker-compose 2026-06-10 23:57:02 +07:00
8 changed files with 20 additions and 127 deletions
-45
View File
@@ -1,45 +0,0 @@
# Git
.git
.gitignore
.gitattributes
# Docker files (tidak perlu masuk image)
docker-compose.yml
.dockerignore
# Dokumentasi
README.md
**/README.md
# SQL files (hanya dipakai untuk init DB, bukan bagian app)
**/setup.sql
**/schema.sql
**/database.sql
**/seed.sql
database/
# Seed scripts (hanya untuk dev)
**/seed.php
# OS & editor junk
.DS_Store
Thumbs.db
desktop.ini
*.swp
*.swo
*~
# IDE
.vscode/
.idea/
*.code-workspace
# Logs
*.log
logs/
# Environment files (jangan masuk image)
.env
.env.*
!.env.example
+1 -10
View File
@@ -1,17 +1,8 @@
FROM php:8.2-apache
# Enable mod_rewrite for clean URLs and .htaccess support
RUN a2enmod rewrite
# Install PHP extensions needed: mysqli (sig-03), pdo + pdo_mysql (sig-01, sig-02)
RUN docker-php-ext-install mysqli pdo pdo_mysql
# Allow .htaccess overrides in /var/www/html
RUN sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf
# Copy all project files into Apache web root
COPY . /var/www/html/
# Fix file permissions
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
RUN chown -R www-data:www-data /var/www/html && chmod -R 755 /var/www/html
+2 -3
View File
@@ -1,7 +1,6 @@
-- ============================================================
-- Combined DB init for Docker
-- Runs automatically on first `docker compose up`
-- Creates: sig_spbu, sig_mapping, sig_bansos
-- Combined DB init
-- Run once to create all databases: sig_spbu, sig_mapping, sig_bansos
-- ============================================================
-- ============================================================
+7 -15
View File
@@ -1,7 +1,5 @@
<?php
// FILE INI HANYA UNTUK INISIALISASI DATABASE
// HAPUS SETELAH DIPAKAI!
// HAPUS FILE INI SETELAH DIPAKAI!
$host = getenv('DB_HOST') ?: 'localhost';
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
@@ -12,8 +10,6 @@ if ($conn->connect_error) {
}
$sqls = file_get_contents(__DIR__ . '/database/init.sql');
// Pisah per statement
$statements = array_filter(array_map('trim', explode(';', $sqls)));
$success = 0;
@@ -29,16 +25,12 @@ foreach ($statements as $sql) {
}
echo "<h2>DB Init Result</h2>";
echo "<p style='color:green'>✅ $success statements executed successfully.</p>";
echo "<p style='color:green'>✅ $success statements OK</p>";
if (!empty($errors)) {
echo "<h3 style='color:red'>Errors (" . count($errors) . "):</h3>";
foreach ($errors as $e) {
echo "<pre style='background:#fee;padding:8px'>$e</pre>";
}
echo "<h3 style='color:orange'>Errors (" . count($errors) . "):</h3>";
foreach ($errors as $e) echo "<pre style='background:#fee;padding:8px'>$e</pre>";
} else {
echo "<p style='color:green'>✅ All done! Semua database berhasil dibuat.</p>";
echo "<p style='color:red'><b>⚠️ HAPUS FILE INI SEKARANG dari repo!</b></p>";
echo "<p style='color:green'><b>✅ Semua database berhasil dibuat!</b></p>";
echo "<p style='color:red'><b>⚠️ Sekarang hapus file ini dari repo!</b></p>";
}
$conn->close();
$conn->close();
-30
View File
@@ -1,30 +0,0 @@
services:
app:
build: .
expose:
- "80"
depends_on:
db:
condition: service_healthy
environment:
DB_HOST: db
restart: unless-stopped
db:
image: mysql:8.0
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: Cb6aGo2ccTVo10wdtU3QM0Ch2yEE8Z1PR9OIXUvmKfAQrCmntWabaQa3JFqi0Vz0
MYSQL_DATABASE: sig_spbu
volumes:
- db_data:/var/lib/mysql
- ./database/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u root -prootpassword || exit 1"]
interval: 10s
timeout: 10s
retries: 15
start_period: 30s
volumes:
db_data:
+2 -8
View File
@@ -1,6 +1,4 @@
<?php
// Konfigurasi koneksi database
// Mendukung environment variable Docker (DB_HOST) maupun hardcoded untuk Laragon
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
define('DB_NAME', 'sig_spbu');
define('DB_USER', getenv('DB_USER') ?: 'root');
@@ -10,11 +8,7 @@ define('DB_CHARSET', 'utf8mb4');
function getDB(): PDO {
static $pdo = null;
if ($pdo !== null) return $pdo;
$dsn = sprintf(
'mysql:host=%s;dbname=%s;charset=%s',
DB_HOST, DB_NAME, DB_CHARSET
);
$dsn = sprintf('mysql:host=%s;dbname=%s;charset=%s', DB_HOST, DB_NAME, DB_CHARSET);
try {
$pdo = new PDO($dsn, DB_USER, DB_PASS, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
@@ -28,4 +22,4 @@ function getDB(): PDO {
exit;
}
return $pdo;
}
}
+2 -8
View File
@@ -1,17 +1,11 @@
<?php
/**
* Koneksi database (PDO).
* Mendukung environment variable Docker (DB_HOST) maupun hardcoded untuk Laragon.
*/
define('DB_HOST', getenv('DB_HOST') ?: '127.0.0.1');
define('DB_PORT', '3306');
define('DB_NAME', 'sig_mapping');
define('DB_USER', getenv('DB_USER') ?: 'root');
define('DB_PASS', getenv('DB_PASS') ?: '');
function db(): PDO
{
function db(): PDO {
static $pdo = null;
if ($pdo === null) {
$dsn = sprintf('mysql:host=%s;port=%s;dbname=%s;charset=utf8mb4', DB_HOST, DB_PORT, DB_NAME);
@@ -22,4 +16,4 @@ function db(): PDO
]);
}
return $pdo;
}
}
+6 -8
View File
@@ -1,19 +1,17 @@
<?php
define('DB_HOST', getenv('DB_HOST') ?: 'localhost');
define('DB_USER', getenv('DB_USER') ?: 'root');
define('DB_PASS', getenv('DB_PASS') ?: '');
define('DB_NAME', 'sig_bansos');
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$host = getenv('DB_HOST') ?: 'localhost';
$user = getenv('DB_USER') ?: 'root';
$pass = getenv('DB_PASS') ?: '';
$db = 'sig_bansos';
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
http_response_code(500);
die(json_encode(['success' => false, 'message' => 'Koneksi database gagal: ' . $conn->connect_error]));
}
$conn->set_charset('utf8mb4');
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Headers: Content-Type');