# Deploying the CRM UI (PM2 + shell script)

Same style as **api.internal-crm**: `deploy/deploy.sh` pulls, installs, builds, and reloads PM2.

**Commands are not environment-specific.** Put settings in repo-root `.env`, then always run `npm run deploy`.
One `.env` per server. Do not commit it.

## First time

```sh
cp .env.example .env
# Set PORT, PM2_APP_NAME, NODE_ENV, NEXT_PUBLIC_*, API_URL for this environment

npm run deploy
```

Point nginx at `127.0.0.1:$PORT`. `API_URL` is server-only (never put secrets in `NEXT_PUBLIC_*`).

## Every deploy

```sh
cd /path/to/internal-crm && npm run deploy
```

## Checking it

```sh
pm2 status
pm2 logs crm-ui --lines 100
```

Default PM2 name is `crm-ui` (override with `PM2_APP_NAME` in `.env`).
