# 0003 - Server-Side Build Pipeline for cPanel

## Context
We needed to automate the deployment process to a cPanel shared/VPS hosting environment. The application uses Node.js (via Phusion Passenger/Application Manager) and Prisma ORM.

Deploying Prisma applications involves compiling OS-specific binary engines during `prisma generate`. If we build the application completely in the CI environment (e.g., an Ubuntu runner in GitHub Actions) and sync the resulting `node_modules` to cPanel, the Prisma binaries will often mismatch the host OS (typically CloudLinux or CentOS), resulting in crashes at runtime.

## Decision
We will use a hybrid deployment pipeline:
1. **GitHub Actions** handles the orchestration, installs dev-dependencies, and compiles TypeScript into JavaScript (`npm run build`). This prevents memory-heavy build steps from crashing the shared cPanel server.
2. Code, including the compiled `dist/` directory, is synced to the cPanel server using **SCP/Rsync**, explicitly excluding `node_modules`.
3. The server-side preparation step (`npm install --production`, `prisma generate`, `prisma migrate deploy`) is executed **natively on the cPanel server** via SSH commands issued by GitHub Actions.
4. The application is restarted gracefully using Passenger's `tmp/restart.txt` convention.

## Consequences
- **Positive:** We guarantee 100% binary compatibility for Prisma by generating the client on the exact OS it will run on.
- **Positive:** We reduce the payload size transferred over the network (syncing source files is much smaller than syncing a full `node_modules` folder).
- **Negative:** The deployment takes slightly longer on the server side, as the server must expend CPU resources to install dependencies and run generators, which could temporarily impact live application performance during the build window. 
- **Negative:** Requires storing the cPanel SSH username/password in GitHub Secrets.
