Add V1 infrastructure: Gitea Actions CI/CD + Fly.io + Cloudflare Pages

- Gitea Actions workflows: ci.yml (tests+clippy+fmt), benchmark.yml (P99 gate), deploy.yml (Fly+CF)
- Fly.io configs: proxy (shared-cpu, 256MB, min 1 machine), API (scale-to-zero)
- Dockerfiles: multi-stage Rust builds for proxy and API binaries
- INFRASTRUCTURE.md: full V1 stack (~$5/mo), AWS migration path, Gitea runner setup, DNS plan
- Stack: Fly.io + Cloudflare Pages + Neon + Upstash + Gitea Actions
This commit is contained in:
2026-03-01 02:37:48 +00:00
parent a486373d93
commit 8a4c7c256d
8 changed files with 295 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
name: Latency Benchmark
on:
push:
branches: [main]
paths: ['products/01-llm-cost-router/src/proxy/**']
jobs:
benchmark:
runs-on: ubuntu-latest # Gitea runner on NAS — consistent CPU
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run proxy latency benchmark
run: cargo bench --bench proxy_latency 2>&1 | tee bench-output.txt
working-directory: products/01-llm-cost-router
- name: Assert P99 < 5ms
run: |
# Extract P99 from criterion output
P99=$(grep -oP 'median\s+\K[\d.]+' bench-output.txt | head -1 || echo "0")
echo "P99 latency: ${P99}ns"
# 5ms = 5,000,000ns
if [ "$(echo "$P99 > 5000000" | bc -l 2>/dev/null || echo 0)" = "1" ]; then
echo "❌ P99 latency ${P99}ns exceeds 5ms budget"
exit 1
fi
echo "✅ P99 within budget"
working-directory: products/01-llm-cost-router

View File

@@ -0,0 +1,56 @@
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
test:
runs-on: ubuntu-latest # Gitea runner on NAS
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo test --workspace
working-directory: products/01-llm-cost-router
- name: Clippy
run: cargo clippy --workspace -- -D warnings
working-directory: products/01-llm-cost-router
- name: Format check
run: cargo fmt --check
working-directory: products/01-llm-cost-router
ui-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install deps
run: npm ci
working-directory: products/01-llm-cost-router/ui
- name: Type check
run: npx tsc --noEmit
working-directory: products/01-llm-cost-router/ui
- name: Build
run: npm run build
working-directory: products/01-llm-cost-router/ui

View File

@@ -0,0 +1,58 @@
name: Deploy
on:
push:
branches: [main]
paths: ['products/01-llm-cost-router/src/**', 'products/01-llm-cost-router/Cargo.*']
jobs:
deploy-proxy:
runs-on: ubuntu-latest
needs: []
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy proxy to Fly.io
run: flyctl deploy --config fly.proxy.toml --remote-only
working-directory: products/01-llm-cost-router
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-api:
runs-on: ubuntu-latest
needs: []
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy API to Fly.io
run: flyctl deploy --config fly.api.toml --remote-only
working-directory: products/01-llm-cost-router
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
deploy-ui:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Build UI
run: |
cd products/01-llm-cost-router/ui
npm ci
npm run build
- name: Deploy to Cloudflare Pages
run: |
npx wrangler pages deploy products/01-llm-cost-router/ui/dist \
--project-name=dd0c-route \
--branch=main
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}