This repository has been archived on 2025-06-09. You can view files and clone it, but cannot push or open issues or pull requests.

44 lines
1.1 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
set -e
REPO_URL=${REPO_URL}
BRANCH=${BRANCH:-main}
TARGET_DIR=/var/www/html
# 1) 初次 clone 或拉取
if [ -z "$(ls -A "$TARGET_DIR")" ]; then
echo "[entrypoint] Cloning $BRANCH from $REPO_URL ..."
git clone --branch "$BRANCH" "$REPO_URL" "$TARGET_DIR"
else
echo "[entrypoint] Repository already present, skipping first clone."
2025-05-29 11:23:06 +08:00
fi
cd "$TARGET_DIR"
2025-05-29 11:23:06 +08:00
# 2) Laravel 基礎安裝
composer install --no-interaction --prefer-dist
2025-05-29 11:23:06 +08:00
[ -f .env ] || cp .env.example .env
2025-05-29 11:23:06 +08:00
update_env() { local k=$1 v=$2; grep -q "^$k=" .env && sed -i "s|^$k=.*|$k=$v|" .env || echo "$k=$v" >> .env; }
update_env APP_NAME "$APP_NAME"
update_env APP_URL "${APP_URL%/}"
update_env DB_HOST "$DB_HOST"
update_env DB_PORT "$DB_PORT"
update_env DB_DATABASE "$DB_DATABASE"
update_env DB_USERNAME "$DB_USERNAME"
update_env DB_PASSWORD "$DB_PASSWORD"
2025-05-29 11:23:06 +08:00
php artisan key:generate --force
2025-05-29 11:23:06 +08:00
php artisan migrate --force
[ -d node_modules ] || npm install
2025-05-29 11:23:06 +08:00
npm run build
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
echo "[entrypoint] Starting supervisord ..."
supervisord -c /etc/supervisor/conf.d/supervisord.conf &
2025-06-02 10:17:50 +08:00
exec "$@"