Commit 9c247613 authored by Administrator's avatar Administrator

Update 2 files via Son of Anton

parent 89dbaf19
...@@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \ ...@@ -11,6 +11,7 @@ RUN apt-get update && apt-get install -y \
zip \ zip \
unzip \ unzip \
default-mysql-client \ default-mysql-client \
dos2unix \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# ── PHP extensions ── # ── PHP extensions ──
...@@ -65,9 +66,9 @@ ENV SMS_PROVIDER= ...@@ -65,9 +66,9 @@ ENV SMS_PROVIDER=
ENV SMS_API_KEY= ENV SMS_API_KEY=
ENV SMS_SENDER_ID= ENV SMS_SENDER_ID=
# ── Entrypoint ── # ── Entrypoint — fix line endings then copy ──
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh RUN dos2unix /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/entrypoint.sh
EXPOSE 80 EXPOSE 80
......
...@@ -6,34 +6,32 @@ echo " THE CLUB ERP — Container Starting" ...@@ -6,34 +6,32 @@ echo " THE CLUB ERP — Container Starting"
echo "=========================================" echo "========================================="
# ── Wait for MySQL to be ready ── # ── Wait for MySQL to be ready ──
echo "Waiting for MySQL at ${DB_HOST}:${DB_PORT}..." echo "Waiting for MySQL at ${DB_HOST}:${DB_PORT}..."
MAX_TRIES=30 MAX_TRIES=30
COUNT=0 COUNT=0
until mysql -h"${DB_HOST}" -P"${DB_PORT}" -u"${DB_USER}" -p"${DB_PASS}" -e "SELECT 1" &>/dev/null; do until mysql -h"${DB_HOST}" -P"${DB_PORT}" -u"${DB_USER}" -p"${DB_PASS}" -e "SELECT 1" &>/dev/null; do
COUNT=$((COUNT + 1)) COUNT=$((COUNT + 1))
if [ $COUNT -ge $MAX_TRIES ]; then if [ $COUNT -ge $MAX_TRIES ]; then
echo "MySQL not ready after ${MAX_TRIES} attempts. Aborting." echo "MySQL not ready after ${MAX_TRIES} attempts. Aborting."
exit 1 exit 1
fi fi
echo " Attempt ${COUNT}/${MAX_TRIES}..." echo " Attempt ${COUNT}/${MAX_TRIES}..."
sleep 2 sleep 2
done done
echo "MySQL is ready!" echo "MySQL is ready!"
# ── Create database if it doesn't exist ── # ── Create database if it doesn't exist ──
echo "📦 Ensuring database '${DB_NAME}' exists..." echo "Ensuring database '${DB_NAME}' exists..."
mysql -h"${DB_HOST}" -P"${DB_PORT}" -u"${DB_USER}" -p"${DB_PASS}" -e \ 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;" "CREATE DATABASE IF NOT EXISTS \`${DB_NAME}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
echo "Database ready!" echo "Database ready!"
# ── Generate .env from environment variables if not exists ── # ── Generate .env from environment variables ──
ENV_FILE="/var/www/html/.env" ENV_FILE="/var/www/html/.env"
if [ ! -f "$ENV_FILE" ]; then cat > "$ENV_FILE" <<EOF
echo "📝 Generating .env from environment variables..."
cat > "$ENV_FILE" <<EOF
APP_URL=${APP_URL:-http://localhost} APP_URL=${APP_URL:-http://localhost}
APP_DEBUG=${APP_DEBUG:-false} APP_DEBUG=${APP_DEBUG:-true}
APP_ENV=${APP_ENV:-production} APP_ENV=${APP_ENV:-local}
DB_HOST=${DB_HOST:-localhost} DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306} DB_PORT=${DB_PORT:-3306}
...@@ -45,36 +43,29 @@ SMS_PROVIDER=${SMS_PROVIDER:-} ...@@ -45,36 +43,29 @@ SMS_PROVIDER=${SMS_PROVIDER:-}
SMS_API_KEY=${SMS_API_KEY:-} SMS_API_KEY=${SMS_API_KEY:-}
SMS_SENDER_ID=${SMS_SENDER_ID:-} SMS_SENDER_ID=${SMS_SENDER_ID:-}
EOF EOF
chown www-data:www-data "$ENV_FILE" chown www-data:www-data "$ENV_FILE"
echo "✅ .env generated!" echo ".env generated!"
else
echo "✅ .env already exists, skipping generation."
fi
# ── Run Migrations ── # ── Run Migrations ──
echo "=========================================" echo "========================================="
echo "🔄 Running Migrations..." echo "Running Migrations..."
echo "=========================================" echo "========================================="
cd /var/www/html cd /var/www/html
php cli.php migrate 2>&1 || { php cli.php migrate 2>&1 || echo "Migration had issues, continuing..."
echo "⚠️ Migration had issues, but continuing..." echo "Migrations complete!"
}
echo "✅ Migrations complete!"
# ── Run Seeds ── # ── Run Seeds ──
echo "=========================================" echo "========================================="
echo "🌱 Running Seeds..." echo "Running Seeds..."
echo "=========================================" echo "========================================="
php cli.php seed 2>&1 || { php cli.php seed 2>&1 || echo "Seeding had issues, continuing..."
echo "⚠️ Seeding had issues, but continuing..." echo "Seeds complete!"
}
echo "✅ Seeds complete!"
# ── Fix permissions after migrations/seeds ── # ── 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 chmod -R 775 /var/www/html/storage 2>/dev/null || true
echo "=========================================" echo "========================================="
echo "🚀 Starting Apache..." echo "Starting Apache..."
echo "=========================================" echo "========================================="
exec apache2-foreground exec apache2-foreground
\ No newline at end of file
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