97 lines
1.8 KiB
Markdown
Raw Normal View History

2025-08-21 15:24:40 +09:00
# Runbook: Development and Production
## Development
2025-08-22 17:02:49 +09:00
1. Setup env and deps
2025-08-21 15:24:40 +09:00
```bash
cp .env.dev.example .env
pnpm install
```
2025-08-22 17:02:49 +09:00
2. Start services (PostgreSQL + Redis)
2025-08-21 15:24:40 +09:00
```bash
pnpm dev:start
```
2025-08-22 17:02:49 +09:00
3. Start the apps (hot reload)
2025-08-21 15:24:40 +09:00
```bash
pnpm dev
# or
pnpm dev:apps
```
2025-08-22 17:02:49 +09:00
4. Migrate database (optional initially)
2025-08-21 15:24:40 +09:00
```bash
pnpm dev:migrate
```
2025-08-22 17:02:49 +09:00
5. Tools (optional)
2025-08-21 15:24:40 +09:00
```bash
pnpm dev:tools # Adminer (http://localhost:8080) + Redis Commander (http://localhost:8081)
```
2025-08-22 17:02:49 +09:00
6. Stop / Status / Logs
2025-08-21 15:24:40 +09:00
```bash
pnpm dev:status
pnpm dev:logs
pnpm dev:stop
```
Notes
2025-08-22 17:02:49 +09:00
2025-08-21 15:24:40 +09:00
- Both apps read env from the root `.env` (centralized).
- Ports are controlled via env:
- `BFF_PORT` (fallback to `PORT`) defaults to 4000
- `NEXT_PORT` defaults to 3000
- Backend API runs on http://localhost:${BFF_PORT} (default 4000; paths start with `/api`).
- Portal runs on http://localhost:${NEXT_PORT} (default 3000).
## Production
2025-08-22 17:02:49 +09:00
1. Setup env
2025-08-21 15:24:40 +09:00
```bash
2025-08-22 17:02:49 +09:00
cp .env.production.example .env
2025-08-21 15:24:40 +09:00
# Edit .env with production values
```
2025-08-22 17:02:49 +09:00
2. (Optional) First-time TLS certificate via HTTP challenge
2025-08-21 15:24:40 +09:00
```bash
# Replace with your domain and email
./scripts/prod/manage.sh issue-cert yourdomain.com you@example.com
```
2025-08-22 17:02:49 +09:00
3. Deploy (build + start + migrate)
2025-08-21 15:24:40 +09:00
```bash
pnpm prod:deploy
```
2025-08-22 17:02:49 +09:00
4. Status / Logs / Update / Stop
2025-08-21 15:24:40 +09:00
```bash
pnpm prod:status
pnpm prod:logs
pnpm prod:update
pnpm prod:stop
```
Endpoints (behind reverse proxy)
2025-08-22 17:02:49 +09:00
2025-08-21 15:24:40 +09:00
- Portal: https://yourdomain.com
- API: https://yourdomain.com/api
- Health: https://yourdomain.com/healthz (proxy) and https://yourdomain.com/api/health (backend)
Security
2025-08-22 17:02:49 +09:00
2025-08-21 15:24:40 +09:00
- Nginx enforces HTTPS, HSTS, CSP and rate limiting for `/api/`.
- Backend disables `x-powered-by`, supports `trust proxy`, and uses centralized env validation.
- Do not commit the `.env` file; keep secrets safe (e.g., `secrets/` volume for keys).