summaryrefslogtreecommitdiff
path: root/git/server-setup.sh
blob: a5756281f77e9c384c32081b9637a24de6916042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Run once on a fresh Hetzner VPS (as root).
# hetzner-infra のみブートストラップとして作成する。
# 他のリポジトリは最初の push 後に git/install.sh が作成する。
set -e

REPO_DIR=/var/git/hetzner-infra.git
APP_DIR=/app/infra

curl -fsSL https://get.docker.com | sh
docker network create web || true

mkdir -p "$REPO_DIR" "$APP_DIR"
git init --bare "$REPO_DIR"

# 最初の push を受け取るための最小限のフック(git/install.sh 実行後に上書きされる)
cat > "$REPO_DIR/hooks/post-receive" << 'HOOK'
#!/bin/bash
set -e
GIT_WORK_TREE=/app/infra git checkout -f
bash /app/infra/caddy/deploy.sh
echo "Deploy complete: hetzner-infra"
HOOK
chmod +x "$REPO_DIR/hooks/post-receive"

echo ""
echo "Next steps:"
echo "  1. git remote add origin root@<server-ip>:$REPO_DIR"
echo "  2. git push origin master"
echo "  3. ssh root@<server-ip> 'bash $APP_DIR/git/install.sh'"