74 lines
1.5 KiB
Bash
74 lines
1.5 KiB
Bash
set -e
|
|
|
|
APP_DIR=/var/www/app
|
|
GIT_URL="https://oauth2:${GIT_TOKEN}@${BACKEND_GIT_REPO}"
|
|
BRANCH="${BACKEND_GIT_BRANCH:-main}"
|
|
FORCE_CLONE="${FORCE_CLONE:-false}"
|
|
|
|
git config --global --add safe.directory "$APP_DIR"
|
|
|
|
if [ ! -d "$APP_DIR/.git" ]; then
|
|
mkdir -p "$APP_DIR"
|
|
echo "azy"
|
|
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
|
|
echo "a"
|
|
else
|
|
cd "$APP_DIR"
|
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
if [ "$CURRENT_BRANCH" = "$BRANCH" ]; then
|
|
echo "b"
|
|
git fetch origin
|
|
git reset --hard origin/"$CURRENT_BRANCH"
|
|
else
|
|
if [ "$FORCE_CLONE" = "true" ]; then
|
|
cd ..
|
|
rm -rf "$APP_DIR"
|
|
mkdir -p "$APP_DIR"
|
|
git clone -b "$BRANCH" "$GIT_URL" "$APP_DIR"
|
|
else
|
|
git fetch origin
|
|
git reset --hard origin/"$BRANCH"
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$APP_DIR"
|
|
|
|
mkdir -p /var/www/.composer/cache
|
|
chown -R www-data:www-data /var/www/.composer
|
|
|
|
if [ -f composer.json ]; then
|
|
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
|
fi
|
|
|
|
cp /tmp/app.env .env
|
|
chown www-data:www-data .env
|
|
chmod 640 .env
|
|
|
|
|
|
|
|
echo "Waiting for MariaDB..."
|
|
until nc -z mariadb 3306; do
|
|
sleep 2
|
|
echo "MariaDB not ready yet..."
|
|
done
|
|
echo "MariaDB is ready!"
|
|
|
|
|
|
|
|
|
|
|
|
php artisan key:generate --force
|
|
php artisan config:clear
|
|
php artisan cache:clear
|
|
php artisan migrate --force
|
|
|
|
chown root:root .env
|
|
chmod 440 .env
|
|
|
|
chown -R www-data:www-data "$APP_DIR/storage" "$APP_DIR/bootstrap/cache"
|
|
chmod -R 775 "$APP_DIR/storage" "$APP_DIR/bootstrap/cache"
|