Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .claude/rules/infra/terraform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
paths:
- infra/**
---

# Infrastructure (Terraform)

```
infra/
├── modules/ # cloud_run, artifact_registry, cloud_tasks, cloudflare, monitoring, service_account
└── environments/ # dev, stg, prod(各環境で tfvars 管理)
```

デプロイ: GitHub Actions で `dev` ブランチ push 時に frontend → Cloudflare Pages、backend → Docker → Artifact Registry → Cloud Run。

DB は Turso (libSQL) を使用。Terraform 対象外で `turso CLI` 手動管理。詳細は `infra/README.md` の「Turso のセットアップ」参照。
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@
"dyld",
"DYLD",
"turso",
"libsql"
"libsql",
"Qiita"
],
"flake8.args": [
"--max-line-length=100"
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ dev-frontend:
preview-frontend:
nix develop --command bash -c "cd frontend && CLOUD_RUN_URL='http://localhost:8000' npm run build && npx wrangler pages dev dist --port 8788"

dev-proxy:
cd frontend && npm run dev:all

dev-proxy-only:
cd frontend && npm run dev:proxy

# ------------------------------------------------------------------ #
# テスト・リント
# ------------------------------------------------------------------ #
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ TURSO_AUTH_TOKEN=

> **注意**: 旧 SQLite ファイル方式(`data/devforge.sqlite` の bind mount, DBeaver の SQLite 直接接続)は廃止しました。

#### Turso (libSQL) ローカル起動

`docker compose up libsql` だけ起動すれば、ホストの `127.0.0.1:8080` に libSQL サーバーが公開されます。
`backend/.env` で以下を設定すれば、ホストの uvicorn から接続できます。

```
TURSO_DATABASE_URL=http://127.0.0.1:8080
TURSO_AUTH_TOKEN=
```

##### TablePlus からローカル libSQL に接続する

1. TablePlus で **新規接続** → **libSQL** を選択
2. **URL** に `http://127.0.0.1:8080` を指定(`docker compose up libsql` 経由)
3. **Token** は空のままで OK
4. **テスト** → **接続**

> **注意**: 旧 SQLite ファイル方式(`data/devforge.sqlite` の bind mount, DBeaver の SQLite 直接接続)は廃止しました。

---

### 本番デプロイ(GCP)
Expand Down
17 changes: 17 additions & 0 deletions backend/app/db/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
from .migrations import run_migrations


def _validate_jwt_keys() -> None:
"""起動時に JWT 鍵ペアの整合性を検証する。署名 → 検証が通らない場合は RuntimeError を送出する。"""
from jose import JWTError, jwt

from ..core.settings import get_jwt_private_key, get_jwt_public_key

try:
priv = get_jwt_private_key()
pub = get_jwt_public_key()
tok = jwt.encode({"sub": "__bootstrap_check__"}, priv, algorithm="RS256")
jwt.decode(tok, pub, algorithms=["RS256"])
except JWTError as e:
raise RuntimeError(
f"JWT 鍵ペアが不正です(秘密鍵と公開鍵が一致しないか、フォーマットが壊れています): {e}"
) from e


def _validate_jwt_keys() -> None:
"""起動時に JWT 鍵ペアの整合性を検証する。署名 → 検証が通らない場合は RuntimeError を送出する。"""
from jose import JWTError, jwt
Expand Down
555 changes: 22 additions & 533 deletions backend/app/db/seed.py

Large diffs are not rendered by default.

Loading
Loading