diff options
Diffstat (limited to 'Deploy.md')
| -rw-r--r-- | Deploy.md | 93 |
1 files changed, 19 insertions, 74 deletions
@@ -1,101 +1,46 @@ # Deploy -Hetzner Cloud + Docker + Caddy (HTTPS) の共有インフラ。 +## 初回サーバーセットアップ -## ディレクトリ構成 +```bash +# 1. Docker + hetzner-infra ブートストラップ +scp git/server-setup.sh root@<server-ip>:~/ +ssh root@<server-ip> 'bash server-setup.sh' -| ディレクトリ | 管理対象 | -|---|---| -| `caddy/` | リバースプロキシ(Caddyfile, docker-compose.yml, deploy.sh) | -| `git/` | ベアリポジトリ・フック(repos.txt, hooks/\*/post-receive, install.sh) | -| `claude/` | Claude Code セッション(sessions.txt, systemd unit, sync.sh) | +# 2. 最初の push(/app/infra に展開される) +git push origin master -## リバースプロキシ(caddy/) +# 3. 残りのリポジトリ作成・全フックインストール・SSH鍵適用 +ssh root@<server-ip> 'bash /app/infra/git/install.sh' +``` -git push 時に post-receive フックが `caddy/deploy.sh` を実行する。 +## 通常デプロイ ```bash -git push origin master +git push origin master # Caddy 設定・コンテナ更新 ``` -Caddyfile 変更時も同様。 - -## git リポジトリ管理(git/) - -`git/repos.txt` と `git/hooks/` で全リポジトリのベアリポジトリとフックを管理する。 -git push では**自動展開しない**。変更後は手動で実行する。 +## フック / リポジトリ定義を変更した場合 ```bash git push origin master ssh root@localhost 'bash /app/infra/git/install.sh' ``` -| ファイル | 役割 | -|---|---| -| `git/repos.txt` | `name:work-tree` 形式でリポジトリを定義 | -| `git/hooks/<repo>/post-receive` | 各リポジトリのフック内容 | -| `git/install.sh` | ベアリポジトリ作成 + フック展開 | - -## Claude Code セッション管理(claude/) - -`claude/sessions.txt` で管理し、手動で同期する。 +## Claude Code セッションを変更した場合 ```bash git push origin master ssh root@localhost 'bash /app/infra/claude/sync.sh' ``` -| ファイル | 役割 | -|---|---| -| `claude/sessions.txt` | `user:repo` 形式でセッションを定義 | -| `claude/systemd/claude-code@.service` | サービステンプレート | -| `claude/sync.sh` | user service を同期 | - -### サービス確認 - -```bash -systemctl --user status 'claude-code@*.service' -tmux ls -``` +## SSH 鍵を追加した場合 -## リポジトリとデプロイ先 +`server/authorized_keys` を編集して push 後に `git/install.sh` を実行。 -| リポジトリ | bare repo | work tree | -|---|---|---| -| hetzner-infra | /var/git/hetzner-infra.git | /app/infra | -| tokyo-livehouse-events | /var/git/tokyo-livehouse-events.git | /app/tokyo-livehouse-events | -| whois-band | /var/git/whois-band.git | /app/whois-band | - -## Docker - -``` -web (external network) - ├── caddy-caddy-1 (80/443) - ├── tokyo-app (golive.yyamashita.com → :3000) - └── whois-app (whoisband.yyamashita.com → :3000) -``` - -- **サーバー**: Hetzner CX22 (Helsinki, Ubuntu 24.04) -- **SSH**: `ssh root@localhost` - -## 新アプリ追加手順 - -1. `git/repos.txt` に `<name>:<work-tree>` を追記 -2. `git/hooks/<name>/post-receive` を作成 -3. `caddy/Caddyfile` にホスト追加 -4. `git push origin master` → `ssh root@localhost 'bash /app/infra/git/install.sh'` -5. 新アプリ側: `git remote add hetzner root@localhost:/var/git/<name>.git` → `git push hetzner master` - -## 初回サーバーセットアップ(再構築時) +## サーバー確認 ```bash -# 1. hetzner-infra をブートストラップ -scp git/server-setup.sh root@<server-ip>:~/ -ssh root@<server-ip> 'bash server-setup.sh' - -# 2. 最初の push(bootstrap hook で /app/infra に展開される) -git push origin master - -# 3. 正式フックをインストール + 他リポジトリ作成 -ssh root@<server-ip> 'bash /app/infra/git/install.sh' +ssh root@localhost 'docker ps' +ssh root@localhost 'docker logs caddy-caddy-1 -f' ``` |
