Add dockerfile and update config file

This commit is contained in:
muthianura
2026-06-11 18:56:34 +07:00
parent f104007f77
commit c66457e587
9 changed files with 83 additions and 19 deletions
+10
View File
@@ -0,0 +1,10 @@
FROM php:8.2-apache
RUN a2enmod rewrite
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
EXPOSE 80
+12
View File
@@ -0,0 +1,12 @@
FROM php:8.2-apache
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN a2enmod rewrite
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
EXPOSE 80
+12
View File
@@ -0,0 +1,12 @@
<?php
define('DB_HOST', getenv('DB_HOST'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASS', getenv('DB_PASS'));
define('DB_NAME', getenv('DB_NAME'));
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$conn->set_charset("utf8");
if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error);
}
?>
+1 -5
View File
@@ -1,7 +1,3 @@
<?php
$conn = new mysqli("localhost", "root", "", "webgis2");
if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error);
}
$conn->set_charset("utf8");
require_once 'config.php';
?>
+17
View File
@@ -0,0 +1,17 @@
FROM php:8.2-apache
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli \
&& apt-get update && apt-get install -y libzip-dev \
&& docker-php-ext-install zip \
&& rm -rf /var/lib/apt/lists/*
RUN a2enmod rewrite
COPY . /var/www/html/
RUN mkdir -p /var/www/html/uploads/foto_rumah \
&& chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html \
&& chmod -R 775 /var/www/html/uploads
EXPOSE 80
+7 -9
View File
@@ -1,14 +1,12 @@
<?php
// config.php - Konfigurasi Database
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', '');
define('DB_NAME', 'gis_penduduk_miskin');
define('DB_HOST', getenv('DB_HOST'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASS', getenv('DB_PASS'));
define('DB_NAME', getenv('DB_NAME'));
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$conn->set_charset('utf8mb4');
if ($conn->connect_error) {
http_response_code(500);
die(json_encode(['error' => 'Database connection failed: ' . $conn->connect_error]));
}
die("Koneksi gagal: " . $conn->connect_error);
}
?>
+12
View File
@@ -0,0 +1,12 @@
FROM php:8.2-apache
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli
RUN a2enmod rewrite
COPY . /var/www/html/
RUN chown -R www-data:www-data /var/www/html \
&& chmod -R 755 /var/www/html
EXPOSE 80
+11
View File
@@ -0,0 +1,11 @@
<?php
define('DB_HOST', getenv('DB_HOST'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASS', getenv('DB_PASS'));
define('DB_NAME', getenv('DB_NAME'));
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error);
}
?>
+1 -5
View File
@@ -1,7 +1,3 @@
<?php
$conn = new mysqli("localhost", "root", "", "webgis");
if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error);
}
require_once 'config.php';
?>