Fix Gitea Actions registry access and runner config
Some checks failed
CI / test-and-build (push) Failing after 1m40s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Your Name 2026-11-17 20:03:55 +02:00
parent 5ce6a6811a
commit 07ccda0349
9 changed files with 144 additions and 16 deletions

View File

@ -31,28 +31,26 @@ jobs:
echo "full=$SHA" >> "$GITHUB_OUTPUT"
- name: Build backend image
env:
REGISTRY: 172.16.0.1:5000
run: |
docker build -t 127.0.0.1:5000/tloto-backend:${{ steps.meta.outputs.sha }} ./backend
docker tag 127.0.0.1:5000/tloto-backend:${{ steps.meta.outputs.sha }} 127.0.0.1:5000/tloto-backend:sha-${{ steps.meta.outputs.sha }}
docker build -t ${REGISTRY}/tloto-backend:${{ steps.meta.outputs.sha }} ./backend
- name: Build web image
env:
REGISTRY: 172.16.0.1:5000
run: |
docker build \
--build-arg VITE_API_BASE_URL=http://127.0.0.1:9080 \
--build-arg VITE_WS_URL=ws://127.0.0.1:9080/ws/v1/games/candle-predict \
--build-arg VITE_WS_ENABLED=true \
-t 127.0.0.1:5000/tloto-web:${{ steps.meta.outputs.sha }} \
-t ${REGISTRY}/tloto-web:${{ steps.meta.outputs.sha }} \
./prediqo_web
- name: Push images to local registry
env:
REGISTRY: 172.16.0.1:5000
run: |
# Host registry published on 127.0.0.1:5000; from job container use gateway.
# act_runner with docker.sock builds on host daemon — 127.0.0.1:5000 works.
docker push 127.0.0.1:5000/tloto-backend:${{ steps.meta.outputs.sha }}
docker push 127.0.0.1:5000/tloto-web:${{ steps.meta.outputs.sha }}
- name: Record artifact markers
run: |
mkdir -p .ci-out
echo "${{ steps.meta.outputs.full }}" > .ci-out/sha.txt
docker push ${REGISTRY}/tloto-backend:${{ steps.meta.outputs.sha }}
docker push ${REGISTRY}/tloto-web:${{ steps.meta.outputs.sha }}
echo "CI_OK ${{ steps.meta.outputs.sha }}"

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Turn ~/games_app tarball into a git checkout of Gitea main while preserving .env and Docker state.
set -euo pipefail
APP="${HOME}/games_app"
TOKEN_FILE="${HOME}/gitea-push-credentials.txt"
TOKEN="$(grep -A1 'Push token' "$TOKEN_FILE" | tail -1 | tr -d ' \r')"
URL="http://tloto-admin:${TOKEN}@127.0.0.1:3000/tloto-admin/games_app.git"
cd "$APP"
cp -a .env /tmp/games_app.env.bak
if [[ ! -d .git ]]; then
git init -b main
git remote add origin "$URL"
else
git remote remove origin 2>/dev/null || true
git remote add origin "$URL"
fi
git fetch origin main
git checkout -f -B main origin/main
# restore secrets
cp -a /tmp/games_app.env.bak .env
chmod 600 .env
# sanitize remote URL (no token)
git remote set-url origin "http://127.0.0.1:3000/tloto-admin/games_app.git"
git status -sb
git rev-parse --short HEAD
echo "APP_GIT_OK"

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
cd ~/gitea
set -a; source .env; set +a
echo "== containers =="
sudo docker ps -a --format '{{.Names}} {{.Status}}' | head -50
echo "== runner =="
sudo docker logs tloto_act_runner --tail 40
echo "== tasks api =="
curl -s -u "${GITEA_ADMIN_USER}:${GITEA_ADMIN_PASSWORD}" \
'http://127.0.0.1:3000/api/v1/repos/tloto-admin/games_app/actions/tasks' | head -c 2000
echo
echo "== runs api alt =="
curl -s -u "${GITEA_ADMIN_USER}:${GITEA_ADMIN_PASSWORD}" \
'http://127.0.0.1:3000/api/v1/repos/tloto-admin/games_app/actions/runs' | head -c 2000
echo

View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Allow HTTP push/pull to local registry from Docker daemon / job containers.
set -euo pipefail
DAEMON=/etc/docker/daemon.json
sudo mkdir -p /etc/docker
if [[ -f "$DAEMON" ]]; then
sudo python3 - <<'PY'
import json
from pathlib import Path
p=Path("/etc/docker/daemon.json")
data=json.loads(p.read_text() or "{}")
regs=set(data.get("insecure-registries") or [])
regs.update(["172.16.0.1:5000", "127.0.0.1:5000"])
data["insecure-registries"]=sorted(regs)
p.write_text(json.dumps(data, indent=2)+"\n")
print(data)
PY
else
echo '{"insecure-registries":["127.0.0.1:5000","172.16.0.1:5000"]}' | sudo tee "$DAEMON"
fi
sudo systemctl restart docker
sleep 3
# restart stacks after docker restart
cd ~/gitea && sudo docker compose up -d gitea registry
sudo docker compose --profile runner up -d runner
cd ~/games_app && sudo docker compose --profile http --profile clamav up -d
curl -fsS http://127.0.0.1:9080/health | head -c 80; echo
curl -fsS http://127.0.0.1:3000/api/v1/version; echo
echo "DOCKER_REGISTRY_OK"

View File

@ -38,7 +38,8 @@ services:
GITEA__security__INTERNAL_TOKEN: ${GITEA_INTERNAL_TOKEN}
GITEA__session__PROVIDER: memory
GITEA__actions__ENABLED: "true"
GITEA__actions__DEFAULT_ACTIONS_URL: self
# Resolve actions/checkout etc. from GitHub (not this instance)
GITEA__actions__DEFAULT_ACTIONS_URL: github
GITEA__openid__ENABLE_OPENID_SIGNIN: "false"
GITEA__openid__ENABLE_OPENID_SIGNUP: "false"
GITEA__mailer__ENABLED: "false"
@ -68,9 +69,10 @@ services:
REGISTRY_STORAGE_DELETE_ENABLED: "true"
volumes:
- registry-data:/var/lib/registry
# Localhost only — CI runner reaches it via Docker network; host builds via 127.0.0.1
# Host loopback + docker0 (job containers cannot use 127.0.0.1 of the host)
ports:
- "127.0.0.1:5000:5000"
- "172.16.0.1:5000:5000"
networks:
- gitea-net
healthcheck:

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
NOW="$(date +%s)"
sudo -u postgres psql -d gitea <<SQL
SELECT id, title, status, started, stopped FROM action_run ORDER BY id DESC LIMIT 8;
SELECT id, run_id, status, started, stopped FROM action_run_job ORDER BY id DESC LIMIT 8;
UPDATE action_run_job SET status = 5, stopped = ${NOW} WHERE status IN (1,2);
UPDATE action_run SET status = 5, stopped = ${NOW} WHERE status IN (1,2);
SQL
cd ~/gitea
sudo docker compose --profile runner up -d --force-recreate runner
sleep 5
sudo docker logs tloto_act_runner --tail 20
echo "ACTIONS_RESET_OK"

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
bash ~/gitea/set-deploy-secrets.sh
cd ~/gitea
set -a; source .env; set +a
echo "--- actions runs ---"
curl -s -u "${GITEA_ADMIN_USER}:${GITEA_ADMIN_PASSWORD}" \
"http://127.0.0.1:3000/api/v1/repos/tloto-admin/games_app/actions/runs?limit=5" | head -c 1200
echo
echo "--- runner logs ---"
sudo docker logs tloto_act_runner --tail 30
echo "--- tloto health ---"
curl -fsS http://127.0.0.1:9080/health | head -c 100; echo
echo "CHECKS_DONE"

View File

@ -14,9 +14,10 @@ cache:
enabled: true
container:
# Jobs run in sibling containers; host docker.sock required for docker build in CI.
# Jobs run as sibling containers via host docker.sock (required for docker build).
# Do not pin to tloto-gitea-net — job containers need Docker Hub + host networking defaults.
privileged: false
network: tloto-gitea-net
network: bridge
options: null
valid_volumes: []
docker_host: ""

View File

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Create repo Actions secrets DEPLOY_SSH_KEY and DEPLOY_SSH_HOST via Gitea API.
set -euo pipefail
cd ~/gitea
set -a; source .env; set +a
BASE="http://127.0.0.1:${GITEA_HTTP_PORT:-3000}"
USER="${GITEA_ADMIN_USER}"
PASS="${GITEA_ADMIN_PASSWORD}"
OWNER="tloto-admin"
REPO="games_app"
KEY="$(cat /home/deploy/gitea-deploy-ssh/id_ed25519)"
HOST="172.16.0.1"
put_secret() {
local name="$1" value="$2"
# Gitea Actions secrets API (1.19+)
code="$(curl -s -o /tmp/gitea-secret.json -w '%{http_code}' -u "${USER}:${PASS}" \
-X PUT -H 'Content-Type: application/json' \
-d "$(python3 -c 'import json,sys; print(json.dumps({"data":sys.argv[1]}))' "$value")" \
"${BASE}/api/v1/repos/${OWNER}/${REPO}/actions/secrets/${name}")"
echo "secret ${name}: HTTP ${code}"
cat /tmp/gitea-secret.json; echo
}
put_secret DEPLOY_SSH_KEY "$KEY"
put_secret DEPLOY_SSH_HOST "$HOST"
echo "SECRETS_OK"