From c73f41dc701f8a62430c1289f0ae4abdae4534c1 Mon Sep 17 00:00:00 2001 From: Remco <1+remco@noreply.gitlabi@epicnabbo.nl> Date: Sat, 18 Jul 2026 15:49:11 +0200 Subject: [PATCH] Update .gitea/workflows/deploy.yaml --- .gitea/workflows/deploy.yaml | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml index 62a4fb89..f9f064b4 100644 --- a/.gitea/workflows/deploy.yaml +++ b/.gitea/workflows/deploy.yaml @@ -11,71 +11,57 @@ jobs: run: | set -e - # 1. Lockfile to prevent concurrent, duplicate deployments + # 1. Deployment lock & init exec 9>/var/tmp/epic_web_control_deploy.lock flock -n 9 || { echo "ERROR: Another deployment is already running! Cancelling."; exit 1; } echo "--- EPIC WEB CONTROL: Starting Auto-Cleanup & Deploy ---" - # Fallback routine on deployment crashes error_handler() { echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2 - echo "Attempting to keep the current service running..." >&2 sudo systemctl restart atom-nexst.service || true exit 1 } trap 'error_handler $LINENO' ERR - # 2. Clean up old system Docker images safely + # 2. Cleanup & Git Sync docker image prune -f - - # 3. Git updates & Permissions configuration cd /var/www/atom-nexst/ git config --global --add safe.directory /var/www/atom-nexst git remote set-url origin /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git/ git fetch origin --prune git reset --hard origin/main - - # Clean untracked files while preserving environment configurations and the Next.js cache (.next/cache) git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next - # Clear old build artifacts but KEEP the cache directory inside .next + # Verwijder oude builds, behoud de cache voor snelheid find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true - # 4. Install dependencies with modern PNPM security rules - # PRISMA_SKIP_POSTINSTALL_GENERATE avoids running duplicate prisma client builds + # 3. Dependencies & Database export PNPM_CONFIG_ONLY_BUILT_DEPENDENCIES="@parcel/watcher,@swc/core,sharp" export PRISMA_SKIP_POSTINSTALL_GENERATE=1 pnpm install --frozen-lockfile - - # 5. Database migrations & Generate Prisma Client pnpm db:migrate pnpm prisma:generate - # 6. Next.js Build (Standalone Mode for Next.js 16 + Turbopack) - # SKIP_ENV_VALIDATION=true prevents Zod from crashing on database URL formatting characters (like %40) during build time + # 4. Standalone Next.js Build export NEXT_DISABLE_SOURCEMAPS=1 export NEXT_TELEMETRY_DISABLED=1 export UV_THREADPOOL_SIZE=2 export SKIP_ENV_VALIDATION=true pnpm build - # 6b. Configure Standalone Bundle Paths + # 5. Sync Standalone Bundle echo "Preparing standalone bundle paths..." - # Copy open assets, media, and static CSS/JS to the standalone bundle path cp -r public .next/standalone/ cp -r .next/static .next/standalone/.next/ - # Copy the core Prisma directory to the standalone node_modules to ensure database actions work cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true - # Explicitly sync your live configuration environment file into the standalone folder cp .env .next/standalone/.env - # 7. Correct file ownership and permissions for the www-data web server user + # 6. Permissions & Restart sudo chown -R www-data:www-data /var/www/atom-nexst/ sudo chmod -R g+rw /var/www/atom-nexst/ - # 8. Restart the Systemd service gracefully (Fast reloads with node server.js) echo "Restarting systemd service gracefully..." sudo systemctl restart atom-nexst.service