# DockerSetup **Özet:** Multi-stage Docker build ile optimize edilmiş imaj üretimi ve docker-compose ile PostgreSQL + Gateway orchestration'ı. **Kütüphaneler:** Docker, docker-compose, Alpine Linux **Bağlantılar:** [[Main]], [[Config]], [[Index]] ## Dockerfile (`docker/Dockerfile`) **Stage 1 — Build:** `golang:1.24-alpine` - Dependency caching için önce `go.mod` + `go.sum` kopyalanır - `CGO_ENABLED=0` ile statik binary - `-ldflags="-w -s"` ile boyut optimizasyonu **Stage 2 — Runtime:** `alpine:3.21` - Sadece binary + `ca-certificates` + `tzdata` - Non-root `gateway` kullanıcısı (güvenlik) - Port 8000 expose ## docker-compose (`docker/docker-compose.yml`) | Servis | İmaj/Rol | Özellikler | |---|---|---| | `app` | LLM Gateway (build) | `.env`'den config, postgres'e bağımlı | | `postgres` | `postgres:16-alpine` | Healthcheck, persistent volume `pgdata` | ### Servis Detayları (app) - Port mapping: `${PORT:-8000}:8000` - Environment: `PORT`, `OPENAI_BACKEND`, `DATABASE_DSN`, `REQUEST_TIMEOUT_SECONDS` - `depends_on` ile postgres healthcheck bekler - `restart: unless-stopped` ## Kullanım ```bash # Tüm stack'i başlat docker compose -f docker/docker-compose.yml up -d # Sadece PostgreSQL (geliştirme) docker compose -f docker/docker-compose.yml up -d postgres # Port override PORT=9000 docker compose -f docker/docker-compose.yml up -d # Sadece imaj build docker build -t optoant-gateway:latest -f docker/Dockerfile . ``` ## Alternatif Derleme ```bash # build.sh ile production binary ./build.sh # Çıktı: ./gateway # Veya direkt Go build CGO_ENABLED=0 go build -ldflags="-w -s" -o gateway ./main.go ```