From 2ee16a6469e7a88f365f2f00aa97fefcf2eb7c65 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 10 Jul 2026 12:39:49 -0500 Subject: [PATCH] Add-github-install-scripts --- CHANGELOG.md | 1 + README.md | 4 ++ docs/INSTALL.md | 38 ++++++++++++++ scripts/install-ubuntu.sh | 107 ++++++++++++++++++++++++++++++++++++++ scripts/update.sh | 16 ++++++ 5 files changed, 166 insertions(+) create mode 100644 docs/INSTALL.md create mode 100644 scripts/install-ubuntu.sh create mode 100644 scripts/update.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2f3f2..0a5590c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This project uses Git as the primary rollback trail. The `.old` convention is re - Added MIT license and first-pass open-source/platform guardrails. - Added deployment documentation covering runtime requirements, ChristIT `/tse` deployment assumptions, and remote change tracking. - Added optional route base-path config and a checked-in Nginx helper for the ChristIT `/tse` Laravel deployment. +- Added first-pass Ubuntu install and update scripts for GitHub-based deployments. ### Verified diff --git a/README.md b/README.md index 5a8debc..36c8ba9 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ npm run build php artisan serve --host=0.0.0.0 --port=8123 ``` +## Server Install + +See `docs/INSTALL.md` for the first-pass Ubuntu/Nginx installer and update script. + ## Demo Accounts All seeded demo accounts use password `password`. diff --git a/docs/INSTALL.md b/docs/INSTALL.md new file mode 100644 index 0000000..8493d24 --- /dev/null +++ b/docs/INSTALL.md @@ -0,0 +1,38 @@ +# Install And Update + +Provider Exchange is a Laravel application. A server install needs PHP-FPM, Nginx, Composer, Node/npm for asset builds, and a database. + +## Quick Ubuntu Install + +From a fresh Ubuntu host: + +```bash +sudo APP_URL=https://example.com \ + APP_DIR=/var/www/technical-services-exchange \ + bash -c "$(curl -fsSL https://raw.githubusercontent.com/jasonybird/technical-services-exchange/main/scripts/install-ubuntu.sh)" +``` + +The installer defaults to SQLite for a small test deployment. For production, use MariaDB/MySQL or PostgreSQL and set the database values in `.env` before running migrations. + +## Update Existing Install + +From the app directory: + +```bash +bash scripts/update.sh +``` + +Or from anywhere: + +```bash +APP_DIR=/var/www/technical-services-exchange bash /var/www/technical-services-exchange/scripts/update.sh +``` + +## Important Notes + +- The installer is a first-pass Ubuntu/Nginx helper, not a universal hosting panel installer. +- Review `.env` before production use. +- Configure real mail before inviting users. +- Move sessions, cache, and queues to Redis before serious traffic. +- Move uploads to shared or object storage before multi-server deployment. +- Use a real database server before treating the platform as production data. diff --git a/scripts/install-ubuntu.sh b/scripts/install-ubuntu.sh new file mode 100644 index 0000000..0e5a6bd --- /dev/null +++ b/scripts/install-ubuntu.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash +set -euo pipefail + +APP_DIR="${APP_DIR:-/var/www/technical-services-exchange}" +REPO_URL="${REPO_URL:-https://github.com/jasonybird/technical-services-exchange.git}" +APP_URL="${APP_URL:-http://localhost}" +APP_BASE_PATH="${APP_BASE_PATH:-}" +ASSET_URL="${ASSET_URL:-$APP_URL}" +DB_CONNECTION="${DB_CONNECTION:-sqlite}" +DB_DATABASE="${DB_DATABASE:-$APP_DIR/database/database.sqlite}" +PHP_FPM_SOCKET="${PHP_FPM_SOCKET:-/run/php/php8.5-fpm.sock}" +NGINX_SITE_NAME="${NGINX_SITE_NAME:-technical-services-exchange}" +WEB_USER="${WEB_USER:-www-data}" + +if [ "$(id -u)" -ne 0 ]; then + echo "Run as root: sudo APP_URL=https://example.com bash scripts/install-ubuntu.sh" >&2 + exit 1 +fi + +apt-get update +apt-get install -y \ + git unzip curl ca-certificates nginx composer \ + php-cli php-fpm php-curl php-mbstring php-xml php-zip php-sqlite3 php-mysql \ + nodejs npm + +mkdir -p "$(dirname "$APP_DIR")" + +if [ -d "$APP_DIR/.git" ]; then + git -C "$APP_DIR" pull --ff-only +else + git clone "$REPO_URL" "$APP_DIR" +fi + +cd "$APP_DIR" + +composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction +npm ci +npm run build + +if [ ! -f .env ]; then + cp .env.example .env +fi + +set_env() { + local key="$1" + local value="$2" + if grep -q "^${key}=" .env; then + sed -i "s#^${key}=.*#${key}=${value}#" .env + else + printf '\n%s=%s\n' "$key" "$value" >> .env + fi +} + +set_env APP_ENV production +set_env APP_DEBUG false +set_env APP_URL "$APP_URL" +set_env APP_BASE_PATH "$APP_BASE_PATH" +set_env ASSET_URL "$ASSET_URL" +set_env DB_CONNECTION "$DB_CONNECTION" +set_env DB_DATABASE "$DB_DATABASE" +set_env SESSION_DRIVER database +set_env SESSION_PATH "${APP_BASE_PATH:-/}" +set_env CACHE_STORE database +set_env QUEUE_CONNECTION database +set_env MAIL_MAILER log + +if [ "$DB_CONNECTION" = "sqlite" ]; then + mkdir -p "$(dirname "$DB_DATABASE")" + touch "$DB_DATABASE" +fi + +php artisan key:generate --force +php artisan migrate --force +php artisan storage:link || true +php artisan optimize:clear +php artisan optimize + +chown -R "$WEB_USER:$WEB_USER" storage bootstrap/cache +if [ "$DB_CONNECTION" = "sqlite" ]; then + chown "$WEB_USER:$WEB_USER" "$DB_DATABASE" +fi + +cat > "/etc/nginx/sites-available/$NGINX_SITE_NAME" <