# Deploy Hetzner Cloud + Docker + Caddy (HTTPS) の共有インフラ。 複数アプリを同一ホストで運用し、Caddy がホスト名でルーティングする。 ## 構成 ``` git push hetzner master (各リポジトリ) └→ /var/git/.git/hooks/post-receive └→ git checkout -f → /app// └→ docker compose up -d (--build) Docker network: web (external, 全アプリ共有) ├── infra-caddy-1 (80/443, HTTPS 自動証明書) ├── tokyo-app (golive.yyamashita.com → :3000) └── whois-app (whois.band → :3000) ``` - **サーバー**: Hetzner CX22 (Helsinki, Ubuntu 24.04) - **SSH**: `ssh golive` ## リポジトリとデプロイ先 | リポジトリ | bare repo | work tree | |---|---|---| | hetzner-infra | /var/git/hetzner-infra.git | /app/infra | | tokyo-livehouse-events | /var/git/tokyo-livehouse-events.git | /app | | whois-band | /var/git/whois-band.git | /app/whois-band | ## デプロイ ```bash git push hetzner master ``` Caddyfile 変更時も同様(push 後に自動 reload)。 ## サーバー操作 ```bash # 全コンテナ確認 ssh golive 'docker ps' # Caddy ログ ssh golive 'docker logs infra-caddy-1 -f' # tokyo ログ ssh golive 'docker logs tokyo-app -f' # whois ログ ssh golive 'docker logs whois-app -f' ``` ## 新アプリ追加手順 1. `Caddyfile` にホスト追加 → `git push hetzner master` 2. 新アプリ側: `docker-compose.yml` で `external: true` の `web` network を使用、`container_name` を設定 3. 新アプリの bare repo をサーバに作成(`scripts/server-setup.sh` 参照) 4. `git remote add hetzner golive:/var/git/.git` 5. `git push hetzner master` ## Claude Code リモートセッション(デーモン) 各リポジトリに対して Claude Code を常駐プロセスとして起動する。 ```bash scp scripts/claude-daemon-setup.sh golive:~/ ssh golive 'bash claude-daemon-setup.sh' ``` 起動後は [https://claude.ai/code](https://claude.ai/code) から各リポジトリのセッションに接続できる。 | サービス名 | 対象ディレクトリ | |---|---| | `claude-infra` | `/app/infra` | | `claude-tokyo` | `/app` | | `claude-whoisband` | `/app/whois-band` | ```bash # 状態確認 ssh golive 'systemctl status claude-tokyo' # ログ確認 ssh golive 'journalctl -u claude-tokyo -f' ``` ## 初回サーバーセットアップ(再構築時) ```bash # 1. hetzner-infra を最初にセットアップ(Docker + web network 作成) scp scripts/server-setup.sh golive:~/ ssh golive 'bash server-setup.sh' git push hetzner master # 2. 各アプリをセットアップ # (各リポジトリの scripts/server-setup.sh を参照) ```