From 5b316b2ef6119746724f4937e046317c98066638 Mon Sep 17 00:00:00 2001 From: Araya's Project <119692205+Araayaaa@users.noreply.github.com> Date: Thu, 11 Jun 2026 00:12:43 +0700 Subject: [PATCH] new configs for deployment --- .dockerignore | 39 ++++++-------------------------------- Dockerfile | 7 +------ db-init.php | 22 +++++++-------------- docker-compose.yml | 24 +---------------------- sig-01/config/database.php | 10 ++-------- sig-02/config/database.php | 10 ++-------- sig-03/koneksi.php | 14 ++++++-------- 7 files changed, 25 insertions(+), 101 deletions(-) diff --git a/.dockerignore b/.dockerignore index d156112..c437bad 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,45 +1,18 @@ -# Git .git .gitignore -.gitattributes - -# Docker files (tidak perlu masuk image) +*.md +**/README.md 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) +database/ .env .env.* !.env.example - \ No newline at end of file +.DS_Store +.vscode/ +*.log \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 330c6b3..9cd1e1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,12 @@ 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 + && chmod -R 755 /var/www/html \ No newline at end of file diff --git a/db-init.php b/db-init.php index 310a974..0616603 100644 --- a/db-init.php +++ b/db-init.php @@ -1,7 +1,5 @@ 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 "

DB Init Result

"; -echo "

✅ $success statements executed successfully.

"; - +echo "

✅ $success statements OK

"; if (!empty($errors)) { - echo "

Errors (" . count($errors) . "):

"; - foreach ($errors as $e) { - echo "
$e
"; - } + echo "

Errors (" . count($errors) . "):

"; + foreach ($errors as $e) echo "
$e
"; } else { - echo "

✅ All done! Semua database berhasil dibuat.

"; - echo "

⚠️ HAPUS FILE INI SEKARANG dari repo!

"; + echo "

✅ Semua database berhasil dibuat!

"; + echo "

⚠️ Sekarang hapus file ini dari repo!

"; } - -$conn->close(); +$conn->close(); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index a9218b8..7c71233 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,30 +3,8 @@ services: build: . expose: - "80" - depends_on: - db: - condition: service_healthy environment: DB_HOST: swc8c4cgcg0s40g04c8k0gso DB_USER: mysql DB_PASS: yPsQNavb6V4loDnXIQz1uluEaQBflV7YsrZBx6HSOXgnK54L85vi1nTdAfWmswDl - 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: \ No newline at end of file + restart: unless-stopped \ No newline at end of file diff --git a/sig-01/config/database.php b/sig-01/config/database.php index 162b4b3..fecc8f3 100644 --- a/sig-01/config/database.php +++ b/sig-01/config/database.php @@ -1,6 +1,4 @@ PDO::ERRMODE_EXCEPTION, @@ -28,4 +22,4 @@ function getDB(): PDO { exit; } return $pdo; -} +} \ No newline at end of file diff --git a/sig-02/config/database.php b/sig-02/config/database.php index e1712d2..c0b5a02 100644 --- a/sig-02/config/database.php +++ b/sig-02/config/database.php @@ -1,17 +1,11 @@ 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'); \ No newline at end of file