Merge pull request #210 from swagfin/master

Added Docker Support Feature
This commit is contained in:
iBNu Maksum 2024-06-19 09:57:51 +07:00 committed by GitHub
commit aad9861d86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 116 additions and 2 deletions

3
.gitignore vendored
View file

@ -39,4 +39,5 @@ system/lan/**
!system/lan/turkish.json
!system/lan/english.json
!system/lan/country.json
*.zip
*.zip
/.vs

26
Dockerfile Normal file
View file

@ -0,0 +1,26 @@
# Use the official PHP image with Apache
FROM php:7.4-apache
EXPOSE 80
# Install necessary PHP extensions
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
zlib1g-dev \
libzip-dev \
zip \
unzip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo pdo_mysql \
&& docker-php-ext-install zip
# copy contents into directory
COPY . /var/www/html
# Set appropriate permissions
RUN chown -R www-data:www-data /var/www/html
RUN chmod -R 755 /var/www/html
# Set working directory
WORKDIR /var/www/html

30
docker-compose.yml Normal file
View file

@ -0,0 +1,30 @@
services:
nuxbill:
container_name: nuxbill
pull_policy: always
build: ./
restart: unless-stopped
ports:
- "80:80"
environment:
TZ: Africa/Nairobi
depends_on:
- mysql
mysql:
container_name: mysql
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: "12345678"
MYSQL_DATABASE: "nuxbill"
MYSQL_USER: "nuxbill"
MYSQL_PASSWORD: "12345678"
ports:
- "3306:3306"
# skip data persistance (if dev testing)
# volumes:
# - mysql_data:/var/lib/mysql
# volumes:
# mysql_data:

View file

@ -13,8 +13,65 @@
<link type='text/css' href='css/style.css' rel='stylesheet' />
<link type='text/css' href="css/bootstrap.min.css" rel="stylesheet">
</head>
<?php if (!file_exists('../pages')) rename('../pages_template', '../pages'); ?>
<?php
$sourceDir = $_SERVER['DOCUMENT_ROOT'].'/pages_template';
$targetDir = $_SERVER['DOCUMENT_ROOT'].'/pages';
function copyDir($src, $dst) {
$dir = opendir($src);
if (!$dir) {
throw new Exception("Cannot open directory: $src");
}
if (!file_exists($dst)) {
if (!mkdir($dst, 0777, true)) {
throw new Exception("Failed to create directory: $dst");
}
}
while (false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
copyDir($src . '/' . $file, $dst . '/' . $file);
} else {
if (!copy($src . '/' . $file, $dst . '/' . $file)) {
throw new Exception("Failed to copy $src/$file to $dst/$file");
}
}
}
}
closedir($dir);
}
function removeDir($dir) {
if (!is_dir($dir)) return;
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object == '.' || $object == '..') continue;
if (is_dir($dir . '/' . $object))
removeDir($dir . '/' . $object);
else
if (!unlink($dir . '/' . $object)) {
throw new Exception("Failed to delete file: $dir/$object");
}
}
if (!rmdir($dir)) {
throw new Exception("Failed to remove directory: $dir");
}
}
try {
if (!file_exists($sourceDir)) {
throw new Exception("Source directory does not exist.");
}
copyDir($sourceDir, $targetDir);
removeDir($sourceDir);
} catch (Exception $e) {
echo 'Error: ', $e->getMessage(), "\n";
}
?>
<body style='background-color: #FBFBFB;'>
<div id='main-container'>
<img src="img/logo.png" class="img-responsive" alt="Logo" />