This commit is contained in:
feng0207
2026-08-11 22:22:10 +08:00
commit 5e312c1266
6985 changed files with 1061169 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#!/bin/bash
set -e
echo "==> Copying Docker swoole config..."
cp /tmp/swoole_docker.php /var/www/html/config/swoole.php
echo "==> Generating .env from environment variables..."
cat > /var/www/html/.env << ENVEOF
APP_DEBUG = true
APP_KEY = "base64:t6/NqsDlNuYSLcdgx//oSVIVBjtRCMa2D6k35Jizla4="
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = ${DB_HOSTNAME:-mysql}
DATABASE = ${DB_DATABASE:-crmeb_chat}
USERNAME = ${DB_USERNAME:-root}
PASSWORD = ${DB_PASSWORD:-root}
HOSTPORT = ${DB_PORT:-3306}
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME = ${REDIS_HOSTNAME:-redis}
PORT = ${REDIS_PORT:-6379}
REDIS_PASSWORD = ${REDIS_PASSWORD:-}
SELECT = 0
ENVEOF
echo "==> Waiting for MySQL..."
until mysqladmin ping -h "${DB_HOSTNAME:-mysql}" -u "${DB_USERNAME:-root}" -p"${DB_PASSWORD:-root}" --silent 2>/dev/null; do
echo " MySQL not ready, retrying..."
sleep 2
done
echo " MySQL is ready!"
echo "==> Importing database schema..."
mysql -h "${DB_HOSTNAME:-mysql}" -u "${DB_USERNAME:-root}" -p"${DB_PASSWORD:-root}" --default-character-set=utf8mb4 "${DB_DATABASE:-crmeb_chat}" < /var/www/html/public/install/crmeb_clean.sql 2>/dev/null && \
echo " Database schema imported." || \
echo " Database may already be initialized (ignoring errors)."
echo "==> Skipping install wizard..."
touch /var/www/html/public/install/install.lock
echo "==> Installing composer dependencies..."
cd /var/www/html
if [ ! -f vendor/autoload.php ]; then
composer install --no-interaction --no-dev --optimize-autoloader
else
echo " Vendors already installed."
fi
echo "==> Cleaning old Swoole PID files..."
rm -f /var/www/html/runtime/swoole.pid /var/www/html/runtime/swoole.log
echo "==> Starting Swoole HTTP server on 0.0.0.0:${SWOOLE_PORT:-20108}..."
exec php think swoole start