# Deploy Hetzner Cloud + Docker + Caddy (HTTPS) の構成。 ## 構成 ``` git push hetzner master └→ /var/git/tokyo-livehouse-events.git/hooks/post-receive └→ git checkout -f → /app └→ docker compose up -d --build ├── app (React Router SSR + Playwright, port 3000) └── caddy (HTTPS 自動証明書, golive.yyamashita.com) ``` - **サーバー**: Hetzner CX22 (Helsinki, Ubuntu 24.04) - **ドメイン**: golive.yyamashita.com - **DB**: SQLite (`/app/data/events.db`、ボリュームで永続化) ## デプロイ ```bash git push hetzner master ``` ## SSH 接続 ```bash ssh golive # ~/.ssh/config に Host golive 設定済み ``` ## サーバー操作 ```bash # ログ確認 ssh golive 'docker compose -f /app/docker-compose.yml logs -f' # コンテナ状態確認 ssh golive 'docker compose -f /app/docker-compose.yml ps' # 手動再起動 ssh golive 'cd /app && docker compose restart' # スクレイピング手動実行(コンテナ内 Node で fetch) ssh golive 'docker exec app-app-1 node -e "fetch(\"http://localhost:3000/api/scrape\").then(r=>r.text()).then(console.log)"' ``` ## スクレイピング定期実行(cron) ```bash ssh golive 'crontab -e' # 以下を追加(毎朝5時): # 0 5 * * * docker exec app-app-1 node -e "fetch('http://localhost:3000/api/scrape').then(r=>r.text()).then(console.log)" ``` ## 初回サーバーセットアップ手順(再構築時) ```bash # 1. SSH 鍵を Hetzner コンソールに登録(~/.ssh/hetzner_golive.pub) # 2. サーバー作成後、セットアップスクリプトを実行 scp scripts/server-setup.sh golive:~/ ssh golive 'bash server-setup.sh' # 3. git remote を追加して push git remote add hetzner golive:/var/git/tokyo-livehouse-events.git git push hetzner master ``` ## ローカル開発 ```bash npm run dev # http://localhost:5173 npm run scrape # スクレイピング実行 ```