fix: simplify Dockerfile and rely on standard apache start to avoid bad gateway
This commit is contained in:
+2
-8
@@ -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"]
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user