feat(deploy): switch to Oracle MySQL, separate CI runner, docker-compose deploy
- Prisma schema: sqlite → mysql provider - Migration SQL rewritten as MySQL DDL (utf8mb4, DATETIME(3), AUTO_INCREMENT) - Add migration_lock.toml for mysql provider - Dockerfile.backend: drop node:22/sqlite deps, use node:20-slim - entrypoint.sh: replace SQLite first-run logic with prisma migrate deploy + db seed - docker-compose.prod.yml: production compose for /opt/webapps/okr on web VPS - reads DB creds from /opt/webapps/webapp-mysql.env - reads app secrets from /opt/webapps/okr/.env.app (written by CI) - port 80 (frontend), no conflict with Gitea 3000/Vault 8200 - ci.yml deploy-okr: moves from ubuntu-latest (web VPS) to ci-runner (161.33.149.243) - builds images on CI runner VPS (no heavy build on web/Gitea VPS) - transfers images via docker save | gzip | ssh | docker load - deploys via SSH + docker compose up on web VPS - scripts/setup-ci-runner.sh: one-time setup script for CI runner VPS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
719f1147d1
commit
9229fee656
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
# Setup act_runner on the CI runner VPS (161.33.149.243).
|
||||
#
|
||||
# Prerequisites (run on CI runner VPS as ubuntu):
|
||||
# 1. Get a runner registration token from Gitea:
|
||||
# http://161.33.139.73:3000 → Site Administration → Runners → "Create Runner"
|
||||
# 2. Generate a deploy SSH key for accessing the web VPS:
|
||||
# ssh-keygen -t ed25519 -f /tmp/deploy_key -N ""
|
||||
# ssh-copy-id -i /tmp/deploy_key.pub ubuntu@161.33.139.73
|
||||
# Add /tmp/deploy_key (private) as Gitea secret: DEPLOY_SSH_KEY
|
||||
# rm /tmp/deploy_key
|
||||
#
|
||||
# Usage:
|
||||
# RUNNER_TOKEN=<token-from-gitea> bash setup-ci-runner.sh
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_URL="http://161.33.139.73:3000"
|
||||
RUNNER_NAME="casan-ci-runner"
|
||||
RUNNER_VERSION="v0.2.12"
|
||||
INSTALL_DIR="/opt/act-runner"
|
||||
|
||||
if [[ -z "${RUNNER_TOKEN:-}" ]]; then
|
||||
echo "ERROR: RUNNER_TOKEN env var is required."
|
||||
echo " Get it from: $GITEA_URL → Site Administration → Runners → Create Runner"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "=== Installing act_runner $RUNNER_VERSION ==="
|
||||
sudo mkdir -p "$INSTALL_DIR"
|
||||
sudo curl -fsSL \
|
||||
"https://gitea.com/gitea/act_runner/releases/download/${RUNNER_VERSION}/act_runner-${RUNNER_VERSION}-linux-amd64" \
|
||||
-o "$INSTALL_DIR/act_runner"
|
||||
sudo chmod +x "$INSTALL_DIR/act_runner"
|
||||
|
||||
echo "=== Writing runner config ==="
|
||||
sudo tee "$INSTALL_DIR/config.yaml" > /dev/null <<'CONFIG'
|
||||
log:
|
||||
level: info
|
||||
|
||||
runner:
|
||||
name: "casan-ci-runner"
|
||||
capacity: 1
|
||||
labels:
|
||||
- "ci-runner:docker://catthehacker/ubuntu:act-22.04"
|
||||
fetch_interval: 5s
|
||||
fetch_timeout: 60s
|
||||
|
||||
container:
|
||||
# host network so the job container can reach Gitea at 161.33.139.73:3000
|
||||
network: host
|
||||
# 2 GB RAM available on CI runner — builds need up to 1.5 GB
|
||||
options: "--memory 1536m --cpus 1.5"
|
||||
valid_volumes:
|
||||
- "**"
|
||||
CONFIG
|
||||
|
||||
echo "=== Registering runner with Gitea ==="
|
||||
cd "$INSTALL_DIR"
|
||||
sudo ./act_runner register \
|
||||
--instance "$GITEA_URL" \
|
||||
--token "$RUNNER_TOKEN" \
|
||||
--name "$RUNNER_NAME" \
|
||||
--no-interactive
|
||||
|
||||
echo "=== Installing systemd service ==="
|
||||
sudo tee /etc/systemd/system/act-runner.service > /dev/null <<'SERVICE'
|
||||
[Unit]
|
||||
Description=Gitea act_runner (CI builds)
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
User=ubuntu
|
||||
Group=docker
|
||||
WorkingDirectory=/opt/act-runner
|
||||
ExecStart=/opt/act-runner/act_runner daemon --config /opt/act-runner/config.yaml
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
SERVICE
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable act-runner
|
||||
sudo systemctl start act-runner
|
||||
|
||||
echo ""
|
||||
echo "=== CI runner setup complete ==="
|
||||
echo "Check status: sudo systemctl status act-runner"
|
||||
echo "View logs: sudo journalctl -u act-runner -f"
|
||||
echo "Verify in Gitea: $GITEA_URL/-/admin/runners"
|
||||
Reference in New Issue
Block a user