Files
Beyhan Ogur a408821410 first commit
2026-05-11 15:08:50 +03:00

61 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
```