Files
member-platform/docs/BACKEND_BOOTSTRAP.md

39 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Backend Bootstrapmemberapi
## 1. 環境準備
```bash
cd member.ose.tw/backend
python -m venv .venv
source .venv/bin/activate
pip install -e .
cp .env.example .env
```
## 2. 建立資料表
1. 先執行 `member.ose.tw/backend/scripts/init_schema.sql`(已含 `api_clients`
2. 若是舊資料庫,補跑 `member.ose.tw/backend/scripts/migrate_align_company_site_member_system.sql`
3. 若是更舊資料庫,再補 `member.ose.tw/backend/scripts/migrate_add_authentik_user_id.sql`
## 3. 啟動服務
```bash
cd member.ose.tw/backend
./scripts/start_dev.sh
```
說明:
- `start_dev.sh` 會用 `--env-file .env.development` 啟動,不需要每次手改 `.env`
## 4. Authentik JWT 最小設定
`.env` 至少填一種:
- `AUTHENTIK_JWKS_URL=<jwks endpoint>`
- `AUTHENTIK_ISSUER=<issuer url>`(系統會推導 `<issuer>/jwks/`
可選:
- `AUTHENTIK_AUDIENCE=<audience>`
- `AUTHENTIK_CLIENT_SECRET=<client_secret>`token 為 HS256 時需要)
## 5. 快速驗證
```bash
curl -sS http://127.0.0.1:8000/healthz
```