From b0b94ecec37d125b8186f13f160f7021d6bcd9f9 Mon Sep 17 00:00:00 2001 From: TigerStable Date: Fri, 12 Jun 2026 21:50:22 +0700 Subject: [PATCH] Untuk Deploy --- .dockerignore | 12 ++++++++++++ Dockerfile | 15 +++++++++++++++ README.md | 24 ++++++++++++++++++++++++ api/init_db.php | 34 +++++++++++++++++++++++----------- 4 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..2b379e2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.gitignore +.agents +.codex +**/.git +**/.git/** +**/.idea +**/.vscode +**/node_modules +deploy.py +README.md + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4d1a3a4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.2-apache + +RUN docker-php-ext-install pdo pdo_mysql \ + && a2enmod headers + +WORKDIR /var/www/html + +COPY . /var/www/html + +RUN chown -R www-data:www-data /var/www/html \ + && find /var/www/html -type d -exec chmod 755 {} \; \ + && find /var/www/html -type f -exec chmod 644 {} \; + +EXPOSE 80 + diff --git a/README.md b/README.md index 12f9481..aeaa065 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,30 @@ Semua data geospasial (titik, garis, poligon) disimpan di MySQL secara fleksibel --- +## Deploy ke Coolify + +Repo ini sudah disiapkan untuk dibuild sebagai container PHP-Apache. Di Coolify, pakai sumber Git dari: + +`https://git.ifuntanhub.dev/RafaelGerhardPanjaitan/UAS_SIG_WebGIS.git` + +Langkah ringkas: + +1. Buat application baru dari Git repository. +2. Pilih build pack `Dockerfile`. +3. Gunakan `Dockerfile` di root repo ini. +4. Hubungkan aplikasi ke service MySQL/MariaDB milik project Coolify Anda. +5. Set environment variables berikut di aplikasi: + - `DB_HOST` + - `DB_NAME` + - `DB_USER` + - `DB_PASS` +6. Import schema dari `database.sql` ke database yang dipakai aplikasi. +7. Pastikan `DB_HOST` menunjuk ke hostname internal database Coolify, bukan `localhost`. + +Jika database belum punya tabel, jalankan `api/init_db.php` sekali dari browser setelah service database aktif, atau import `database.sql` langsung dari panel database Coolify. + +--- + ## 🚀 Panduan Instalasi & Menjalankan Aplikasi Karena aplikasi ini sekarang menggunakan **PHP dan MySQL**, Anda tidak bisa langsung membuka file HTML-nya. Ikuti langkah berikut menggunakan **XAMPP**: diff --git a/api/init_db.php b/api/init_db.php index 69ac316..0361881 100644 --- a/api/init_db.php +++ b/api/init_db.php @@ -1,18 +1,30 @@ exec($sql); + $pdo->exec(" + CREATE TABLE IF NOT EXISTS features ( + id VARCHAR(100) PRIMARY KEY, + layer VARCHAR(50) NOT NULL, + data JSON NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + "); + + $stmt = $pdo->prepare(" + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = DATABASE() + AND table_name = 'features' + AND index_name = 'idx_layer' + LIMIT 1 + "); + $stmt->execute(); + + if (!$stmt->fetchColumn()) { + $pdo->exec("CREATE INDEX idx_layer ON features(layer)"); + } + echo "Database table 'features' created successfully."; } catch (PDOException $e) { echo "Error creating table: " . $e->getMessage();