- Updated .env.example to recommend using docker.env and secrets for sensitive data. - Modified .gitignore to include docker.env and secrets directory. - Adjusted docker-compose.yml to utilize environment files and updated port mappings. - Implemented read_env_or_file utility for better environment variable management. - Refactored portfolio and trades routers to use the new utility for fetching environment variables. - Added integration and phase 2 test updates for new environment variable handling. - Created new documentation for Docker operations and secret management. - Added placeholder files for Docker secrets and configuration.
4.0 KiB
IBKR Dashboard Operasyon Rehberi
Bu rehber, projeyi yerelde Docker ile baslatmak, saglik kontrolu yapmak, smoke test calistirmak ve guvenli sekilde kapatmak icin kisa bir operasyon akisi verir.
1. Onkosullar
- Docker Desktop calisiyor olmali.
- Docker icin repo kokunde
docker.envdosyasi olmali. - Lokal Python calismalari icin isterseniz ayri bir
.envdosyasi tutabilirsiniz. .envicindekiWEBHOOK_SECRETvarsayilan degerde birakilmamali.- Docker secret dosyalari
./secretsaltinda olusturulmali.
2. Hazirlik
docker.env.example dosyasini docker.env olarak kopyalayin. Ardindan gerekli secret dosyalarini olusturun:
cp docker.env.example docker.env
mkdir -p secrets
printf '%s\n' 'your_ibkr_password' > secrets/tws_password
printf '%s\n' 'change_this_webhook_secret' > secrets/webhook_secret
chmod 600 secrets/tws_password secrets/webhook_secret
docker network inspect traefik-public >/dev/null 2>&1 || docker network create traefik-public
Notlar:
primaryoverride, mevcut bir IBKR oturumu varsa gateway'in login dialogunda takilma riskini azaltir.- Uygulama SQLite veritabani icin
./datadizinini kullanir. Dizin repo icinde mevcut olmali. - Opsiyonel secret dosyalari:
secrets/vnc_password,secrets/ui_username,secrets/ui_password.
3. Stack Baslatma
Servisleri build edip arka planda kaldirin:
docker compose --env-file docker.env up -d --build
Durumu kontrol edin:
docker compose --env-file docker.env ps -a
Beklenen durum:
ib-gateway:Up (healthy)ibkr-dashboard:Upveya kisa sure sonraUp (healthy)
Log takibi icin:
docker compose --env-file docker.env logs -f ib-gateway ibkr-dashboard
4. Health Kontrolu
Uygulama health endpoint'ini dogrulayin:
curl -sS --max-time 10 http://localhost:8000/health
Beklenen cevap ornegi:
{"status":"ok","ib_connected":true,"account":"...","db_ok":true,"version":"3.0"}
status=ok, ib_connected=true ve db_ok=true gorulmelidir.
5. Test ve Smoke Dogrulama
Offline test paketi:
pytest tests/ -q --tb=short
Beklenen sonuc:
47 passed, 2 skipped
Docker smoke testi:
./verify_docker.sh
Guncel dogrulanmis durum:
- Script 18/18 check geciyor.
Canli IB entegrasyon testlerini ozellikle acmak isterseniz:
RUN_LIVE_IB_TESTS=1 pytest tests/test_integration.py -q --tb=short
6. Sorun Giderme
Docker Compose $ warning'i
Semptom:
The "K4" variable is not set. Defaulting to a blank string.
Cozum:
- Compose komutlarini
.env.docker.tmpile calistirin. - Docker icin
docker compose --env-file docker.env ...kullanin. - Secret degerlerini
./secretsaltindaki dosyalardan okuyun.
Gateway login oluyor ama healthy olmuyor
Kontrol edin:
docker compose --env-file docker.env logs --tail=100 ib-gateway
Beklenen satirlar:
Login has completedConfiguration tasks completed
Dashboard ayaga kalkmiyor
Kontrol edin:
docker compose --env-file docker.env logs --tail=100 ibkr-dashboard
Ozellikle su hatalara bakin:
sqlite3.OperationalError: unable to open database fileTimeoutErrorveya IB gateway baglanti hatalari
7. Kapatma
Servisleri temiz kapatmak icin:
docker compose --env-file docker.env down --remove-orphans
Docker secret dosyalarini yerinde birakip sadece docker.env kaldirilabilir:
rm -f docker.env
8. Operasyon Notlari
verify_docker.sh, varsayilan olarakdocker.envvarsa onu kullanir; yoksa.env'e geri duser.- Docker ic aginda dashboard, gateway'e
ib-gateway:4004uzerinden baglanir. - Host makinede paper API erisimi
127.0.0.1:4002, live API erisimi127.0.0.1:4001olarak map edilir.
9. Geriye Donuk Fallback
Eger mevcut .env ile devam etmek zorundaysaniz, eski gecici dosya akisi hala kullanilabilir:
sed 's/\$/\$\$/g' .env > .env.docker.tmp
COMPOSE_ENV_FILE=.env.docker.tmp COMPOSE_APP_ENV_FILE=.env.docker.tmp ./verify_docker.sh