diff --git a/Dockerfile b/Dockerfile index 1292d9f..99f42e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,17 @@ FROM php:8.2-apache -# Install mysql client dan ekstensi PHP +# Install ekstensi PHP yang dibutuhkan (termasuk PDO dan MySQLi) RUN apt-get update && apt-get install -y default-mysql-client && rm -rf /var/lib/apt/lists/* RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable mysqli # Aktifkan mod_rewrite Apache RUN a2enmod rewrite -# Copy semua file project ke dalam container +# Copy semua file project COPY . /var/www/html/ -# Copy entrypoint script -COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN chmod +x /usr/local/bin/docker-entrypoint.sh - # Update permissions RUN chown -R www-data:www-data /var/www/html # Expose port Apache EXPOSE 80 - -ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 26833f1..0000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -echo "=== Starting WebGIS Application ===" - -# Jalankan setup database di background (tidak blokir Apache) -( - echo "Background: Waiting for MySQL at $DB_HOST..." - MAX_TRIES=30 - COUNT=0 - until mysql -h"$DB_HOST" -uroot -p"$DB_PASS" -e "SELECT 1" > /dev/null 2>&1; do - COUNT=$((COUNT+1)) - if [ $COUNT -ge $MAX_TRIES ]; then - echo "Background: MySQL timeout, skipping DB setup." - exit 0 - fi - echo "Background: MySQL not ready ($COUNT/$MAX_TRIES), retrying..." - sleep 5 - done - - echo "Background: MySQL ready! Setting up databases..." - - mysql -h"$DB_HOST" -uroot -p"$DB_PASS" < /var/www/html/WEBGIS/01/api/setup_webgis.sql \ - && echo "Background: webgis OK!" \ - || echo "Background: webgis already exists, skipped." - - mysql -h"$DB_HOST" -uroot -p"$DB_PASS" \ - -e "CREATE DATABASE IF NOT EXISTS kemiskinan_ibadah CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" - - mysql -h"$DB_HOST" -uroot -p"$DB_PASS" kemiskinan_ibadah \ - < /var/www/html/webtugas/01/api/setup_webtugas.sql \ - && echo "Background: kemiskinan_ibadah OK!" \ - || echo "Background: kemiskinan_ibadah already exists, skipped." - - echo "Background: === Database setup complete ===" -) & - -echo "=== Starting Apache now ===" - -# Start Apache langsung (tidak tunggu DB) -exec apache2-foreground