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 \
zip \
unzip \
default-mysql-client \
dos2unix \
&& rm -rf /var/lib/apt/lists/*
# ── PHP extensions ──
......@@ -65,9 +66,9 @@ ENV SMS_PROVIDER=
ENV SMS_API_KEY=
ENV SMS_SENDER_ID=
# ── Entrypoint ──
# ── Entrypoint — fix line endings then copy ──
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
......
......@@ -6,34 +6,32 @@ echo " THE CLUB ERP — Container Starting"
echo "========================================="
# ── 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
COUNT=0
until mysql -h"${DB_HOST}" -P"${DB_PORT}" -u"${DB_USER}" -p"${DB_PASS}" -e "SELECT 1" &>/dev/null; do
COUNT=$((COUNT + 1))
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
fi
echo " Attempt ${COUNT}/${MAX_TRIES}..."
sleep 2
done
echo "MySQL is ready!"
echo "MySQL is ready!"
# ── 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 \
"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"
if [ ! -f "$ENV_FILE" ]; then
echo "📝 Generating .env from environment variables..."
cat > "$ENV_FILE" <<EOF
cat > "$ENV_FILE" <<EOF
APP_URL=${APP_URL:-http://localhost}
APP_DEBUG=${APP_DEBUG:-false}
APP_ENV=${APP_ENV:-production}
APP_DEBUG=${APP_DEBUG:-true}
APP_ENV=${APP_ENV:-local}
DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306}
......@@ -45,36 +43,29 @@ SMS_PROVIDER=${SMS_PROVIDER:-}
SMS_API_KEY=${SMS_API_KEY:-}
SMS_SENDER_ID=${SMS_SENDER_ID:-}
EOF
chown www-data:www-data "$ENV_FILE"
echo "✅ .env generated!"
else
echo "✅ .env already exists, skipping generation."
fi
chown www-data:www-data "$ENV_FILE"
echo ".env generated!"
# ── Run Migrations ──
echo "========================================="
echo "🔄 Running Migrations..."
echo "Running Migrations..."
echo "========================================="
cd /var/www/html
php cli.php migrate 2>&1 || {
echo "⚠️ Migration had issues, but continuing..."
}
echo "✅ Migrations complete!"
php cli.php migrate 2>&1 || echo "Migration had issues, continuing..."
echo "Migrations complete!"
# ── Run Seeds ──
echo "========================================="
echo "🌱 Running Seeds..."
echo "Running Seeds..."
echo "========================================="
php cli.php seed 2>&1 || {
echo "⚠️ Seeding had issues, but continuing..."
}
echo "✅ Seeds complete!"
php cli.php seed 2>&1 || echo "Seeding had issues, continuing..."
echo "Seeds complete!"
# ── Fix permissions after migrations/seeds ──
# ── Fix permissions ──
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 "========================================="
echo "🚀 Starting Apache..."
echo "Starting Apache..."
echo "========================================="
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