Commit 4ca9dedd authored by Administrator's avatar Administrator

Update 18 files via Son of Anton

parent 1b7c366e
Pipeline #13 canceled with stage
...@@ -6,9 +6,9 @@ DB_HOST=srv-captain--mysql-db ...@@ -6,9 +6,9 @@ DB_HOST=srv-captain--mysql-db
DB_PORT=3306 DB_PORT=3306
DB_NAME=al_arcade_hr DB_NAME=al_arcade_hr
DB_USER=root DB_USER=root
DB_PASS=CHANGE_ME DB_PASS=Alarcade123#
SA_USERNAME=mahmoud SA_USERNAME=admin
SA_PASSWORD=CHANGE_ME SA_PASSWORD=Alarcade123#
SA_NAME_EN=Mahmoud Aglan SA_NAME_EN=Mahmoud Aglan
SA_NAME_AR=محمود عجلان SA_NAME_AR=محمود عجلان
\ No newline at end of file
FROM php:8.2-apache FROM php:8.2-apache
# Install PHP extensions # Install PHP extensions + MySQL client for entrypoint
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
libpng-dev \ libpng-dev \
libjpeg-dev \ libjpeg-dev \
...@@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y \ ...@@ -10,6 +10,7 @@ RUN apt-get update && apt-get install -y \
libonig-dev \ libonig-dev \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
zip unzip curl \ zip unzip curl \
default-mysql-client \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \ && docker-php-ext-install \
pdo_mysql \ pdo_mysql \
......
...@@ -3,8 +3,8 @@ declare(strict_types=1); ...@@ -3,8 +3,8 @@ declare(strict_types=1);
spl_autoload_register(function (string $class): void { spl_autoload_register(function (string $class): void {
$prefixes = [ $prefixes = [
'Engine\\' => ROOT_PATH . '/engine/', 'Engine\\' => ROOT_PATH . '/engine/',
'Modules\\' => ROOT_PATH . '/modules/', 'Modules\\' => ROOT_PATH . '/modules/',
'Middleware\\' => ROOT_PATH . '/middleware/', 'Middleware\\' => ROOT_PATH . '/middleware/',
]; ];
......
...@@ -22,8 +22,8 @@ if ($stmt->fetch()) { ...@@ -22,8 +22,8 @@ if ($stmt->fetch()) {
exit(0); exit(0);
} }
$username = $_ENV['SA_USERNAME'] ?? 'mahmoud'; $username = $_ENV['SA_USERNAME'] ?? 'admin';
$password = $_ENV['SA_PASSWORD'] ?? 'Admin@12345'; $password = $_ENV['SA_PASSWORD'] ?? 'Alarcade123#';
$nameEn = $_ENV['SA_NAME_EN'] ?? 'Mahmoud Aglan'; $nameEn = $_ENV['SA_NAME_EN'] ?? 'Mahmoud Aglan';
$nameAr = $_ENV['SA_NAME_AR'] ?? 'محمود عجلان'; $nameAr = $_ENV['SA_NAME_AR'] ?? 'محمود عجلان';
...@@ -47,7 +47,8 @@ $stmt = $pdo->prepare(" ...@@ -47,7 +47,8 @@ $stmt = $pdo->prepare("
try { try {
$stmt->execute([$username, $hash, $nameEn, $nameAr, $nameEn]); $stmt->execute([$username, $hash, $nameEn, $nameAr, $nameEn]);
echo "✅ Super Admin created: {$username}\n"; echo "✅ Super Admin created successfully.\n";
echo " Username: {$username}\n";
echo " Password: {$password}\n"; echo " Password: {$password}\n";
echo " ⚠️ Force password change is ON. Change on first login.\n"; echo " ⚠️ Force password change is ON. Change on first login.\n";
} catch (PDOException $e) { } catch (PDOException $e) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
/** /**
* Cron entry point. Run every minute: * Cron entry point. Add to crontab:
* * * * * * php /var/www/html/cron/runner.php >> /var/www/html/storage/logs/cron.log 2>&1 * * * * * * php /var/www/html/cron/runner.php >> /var/www/html/storage/logs/cron.log 2>&1
*/ */
......
...@@ -3,46 +3,56 @@ set -e ...@@ -3,46 +3,56 @@ set -e
echo "=== AL-ARCADE HR Platform v3.0 — Starting ===" echo "=== AL-ARCADE HR Platform v3.0 — Starting ==="
# Wait for MySQL to be ready DB_HOST="${DB_HOST:-srv-captain--mysql-db}"
echo "Waiting for MySQL..." DB_PORT="${DB_PORT:-3306}"
DB_USER="${DB_USER:-root}"
DB_PASS="${DB_PASS:-Alarcade123#}"
DB_NAME="${DB_NAME:-al_arcade_hr}"
# Wait for MySQL
echo "Waiting for MySQL at ${DB_HOST}:${DB_PORT}..."
MAX_TRIES=30 MAX_TRIES=30
COUNT=0 COUNT=0
while ! php -r "try { new PDO('mysql:host=${DB_HOST:-srv-captain--mysql-db};port=${DB_PORT:-3306}', '${DB_USER:-root}', '${DB_PASS:-Alarcade123#}'); echo 'OK'; } catch(Exception \$e) { exit(1); }" 2>/dev/null; do while ! mysqladmin ping -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" --silent 2>/dev/null; do
COUNT=$((COUNT + 1)) COUNT=$((COUNT + 1))
if [ $COUNT -ge $MAX_TRIES ]; then if [ $COUNT -ge $MAX_TRIES ]; then
echo "ERROR: MySQL not available after ${MAX_TRIES} attempts. Starting anyway..." echo "ERROR: MySQL not available after ${MAX_TRIES} attempts. Starting anyway..."
break break
fi fi
echo " MySQL not ready yet... (attempt $COUNT/$MAX_TRIES)" echo " MySQL not ready... (attempt $COUNT/$MAX_TRIES)"
sleep 2 sleep 2
done done
echo "MySQL is up."
# Create database if it doesn't exist
echo "Ensuring database exists..."
mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" -e "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" 2>/dev/null || true
# Run schema if database is empty # Check table count
TABLE_COUNT=$(php -r " TABLE_COUNT=$(mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" -N -e "SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${DB_NAME}';" 2>/dev/null || echo "0")
try {
\$pdo = new PDO('mysql:host=${DB_HOST:-srv-captain--mysql-db};port=${DB_PORT:-3306};dbname=${DB_NAME:-al_arcade_hr}', '${DB_USER:-root}', '${DB_PASS:-Alarcade123#}');
\$r = \$pdo->query(\"SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${DB_NAME:-al_arcade_hr}'\");
echo \$r->fetchColumn();
} catch(Exception \$e) { echo '0'; }
" 2>/dev/null || echo "0")
if [ "$TABLE_COUNT" -lt "70" ]; then if [ "$TABLE_COUNT" -lt "70" ]; then
echo "Database has $TABLE_COUNT tables (need 73). Running schema..." echo "Database has $TABLE_COUNT tables (need 73). Running schema..."
if [ -f /var/www/html/database/schema.sql ]; then if [ -f /var/www/html/database/schema.sql ]; then
mysql -h "${DB_HOST:-srv-captain--mysql-db}" -P "${DB_PORT:-3306}" -u "${DB_USER:-root}" -p"${DB_PASS:-Alarcade123#}" < /var/www/html/database/schema.sql 2>/dev/null && echo "Schema deployed." || echo "Schema deployment failed or already exists." mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" < /var/www/html/database/schema.sql 2>&1 && echo "✅ Schema deployed." || echo "⚠️ Schema may already exist."
else
echo "❌ schema.sql not found!"
fi fi
echo "Running seed data..." echo "Running seed data..."
if [ -f /var/www/html/database/seed.sql ]; then if [ -f /var/www/html/database/seed.sql ]; then
mysql -h "${DB_HOST:-srv-captain--mysql-db}" -P "${DB_PORT:-3306}" -u "${DB_USER:-root}" -p"${DB_PASS:-Alarcade123#}" "${DB_NAME:-al_arcade_hr}" < /var/www/html/database/seed.sql 2>/dev/null && echo "Seed data applied." || echo "Seed already exists or failed." mysql -h "$DB_HOST" -P "$DB_PORT" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" < /var/www/html/database/seed.sql 2>&1 && echo "✅ Seed data applied." || echo "⚠️ Seed data may already exist."
fi fi
echo "Creating super admin..." echo "Creating super admin..."
php /var/www/html/cli/create-superadmin.php 2>/dev/null || echo "Super admin may already exist." php /var/www/html/cli/create-superadmin.php 2>&1 || echo "⚠️ Super admin may already exist."
else else
echo "Database has $TABLE_COUNT tables. Skipping schema." echo "Database has $TABLE_COUNT tables. Schema OK. Skipping."
fi fi
# Fix permissions # Fix permissions
chown -R www-data:www-data /var/www/html/storage 2>/dev/null || true chown -R www-data:www-data /var/www/html/storage 2>/dev/null || true
chmod -R 775 /var/www/html/storage 2>/dev/null || true
echo "=== Ready. Launching Apache ===" echo "=== AL-ARCADE HR v3.0 Ready. Launching Apache ==="
exec "$@" exec "$@"
\ No newline at end of file
; AL-ARCADE HR Platform — Production PHP Config
upload_max_filesize = 25M upload_max_filesize = 25M
post_max_size = 30M post_max_size = 30M
memory_limit = 512M memory_limit = 512M
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment