diff options
| author | yyamashita <yyamashita@mosquit.one> | 2026-05-08 23:46:45 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@mosquit.one> | 2026-05-08 23:46:45 +0900 |
| commit | fe47704e9bf8d87b96b2f27b9bf3c3f6b0867039 (patch) | |
| tree | 28a11e55d61a9ac9960d5222dc9d76de60428a7d /scripts | |
| parent | 73a035d82eb5dc27c56251e5466f6c8af0a1d0a1 (diff) | |
Add server-setup.sh: bare repo, web network, Caddy post-receive hook
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/server-setup.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/scripts/server-setup.sh b/scripts/server-setup.sh new file mode 100644 index 0000000..ce2ad87 --- /dev/null +++ b/scripts/server-setup.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# Run once on a fresh Hetzner VPS (as root). Run this first before other app setups. +set -e + +APP_DIR=/app/infra +REPO_DIR=/var/git/hetzner-infra.git + +# Install Docker +curl -fsSL https://get.docker.com | sh + +# Create shared Docker network +docker network create web || true + +mkdir -p "$APP_DIR" + +mkdir -p "$REPO_DIR" +git init --bare "$REPO_DIR" + +cat > "$REPO_DIR/hooks/post-receive" << 'EOF' +#!/bin/bash +set -e +APP_DIR=/app/infra +GIT_WORK_TREE=$APP_DIR git checkout -f +cd $APP_DIR +docker compose up -d +docker compose exec -T caddy caddy reload --config /etc/caddy/Caddyfile +echo "Deploy complete: hetzner-infra" +EOF + +chmod +x "$REPO_DIR/hooks/post-receive" + +echo "" +echo "Setup complete. On your local machine, run:" +echo " git remote add hetzner root@<server-ip>:$REPO_DIR" +echo " git push hetzner master" +echo "" +echo "Then run setup scripts for each app:" +echo " tokyo-livehouse-events/scripts/server-setup.sh" +echo " whois-band/scripts/server-setup.sh" |
