9a8f9941b6
Deploy Iddaai Backend / build-and-deploy (push) Successful in 54s
Add IMAGE_BASE_URL to the deploy env so the backend builds image URLs against the Cloudflare image-proxy Worker instead of mackolik, and check in the Worker source (already live on files.iddaai.com). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
52 lines
1.6 KiB
Markdown
52 lines
1.6 KiB
Markdown
# iddaai image proxy (Cloudflare Worker + R2)
|
||
|
||
Takım / lig / ülke görsellerini R2'den servis eden lazy-fill proxy.
|
||
İstek akışı: **edge cache → R2 → upstream (mackolik) → R2'ye yaz**.
|
||
Bucket kendi kendine dolar; bir görsel R2'ye girdikten sonra upstream
|
||
kaldırsa bile kalıcıdır.
|
||
|
||
## Canlı kurulum (2026-06-10)
|
||
|
||
- Worker: `iddaai-image-proxy` (dashboard üzerinden deploy edildi)
|
||
- Bucket: `iddaai-images` (binding adı: `BUCKET`)
|
||
- Domain: `https://files.iddaai.com`
|
||
- BE env: `IMAGE_BASE_URL=https://files.iddaai.com` (.gitea/workflows/deploy.yml)
|
||
|
||
Dashboard'daki kod ile `src/index.ts` aynı mantıktır (dashboard'da JS,
|
||
burada TS). Kod değişikliği gerekirse ikisini senkron tut veya
|
||
`npm run deploy` ile buradan deploy et.
|
||
|
||
## URL şeması (upstream ile birebir aynı)
|
||
|
||
```
|
||
GET /teams/<teamId> → takım logosu
|
||
GET /competitions/<leagueId> → lig logosu
|
||
GET /areas/<countryId> → ülke bayrağı
|
||
```
|
||
|
||
## CLI ile geliştirme / deploy
|
||
|
||
```bash
|
||
cd workers/image-proxy
|
||
npm install
|
||
npm run dev # lokal test (miniflare, lokal R2 simülasyonu)
|
||
npm run typecheck
|
||
npx wrangler login # ilk seferde
|
||
npm run deploy
|
||
```
|
||
|
||
## Bucket'ı önceden doldurma (opsiyonel)
|
||
|
||
```bash
|
||
../../scripts/warm-image-cache.sh https://files.iddaai.com
|
||
```
|
||
|
||
Prod sunucuda çalışır; DB'deki tüm takım/lig/ülke ID'lerini Worker
|
||
üzerinden bir kez ister, Worker her birini R2'ye yazar (~20K istek,
|
||
~200 MB). Çalıştırılmasa da bucket trafikle kendi kendine dolar.
|
||
|
||
## Maliyet
|
||
|
||
R2 free tier: 10 GB depolama + sınırsız egress. Workers free tier:
|
||
100K istek/gün. Bu ölçekte aylık maliyet: 0.
|