first commit
This commit is contained in:
223
belgeler/PRODUCTION_WEBP.md
Normal file
223
belgeler/PRODUCTION_WEBP.md
Normal file
@@ -0,0 +1,223 @@
|
||||
# Production Build - WebP Desteği
|
||||
|
||||
## ✅ Değişiklikler
|
||||
|
||||
### 1. WebP Desteği Geri Eklendi
|
||||
- ✅ `github.com/chai2010/webp` dependency eklendi
|
||||
- ✅ Varsayılan avatar format: **WebP**
|
||||
- ✅ CGO enabled build
|
||||
|
||||
### 2. Docker Configuration
|
||||
- ✅ **CGO_ENABLED=1** (WebP için gerekli)
|
||||
- ✅ **libwebp-dev** build dependency
|
||||
- ✅ **libwebp** runtime dependency
|
||||
- ✅ Static linking ile portable binary
|
||||
|
||||
### 3. docker-compose.prod.yml
|
||||
- ✅ **Sadece uygulama** servisi
|
||||
- ❌ PostgreSQL yok (Dokploy managed)
|
||||
- ❌ Redis yok (Dokploy managed)
|
||||
- ✅ Harici DB/Redis connection ayarları
|
||||
|
||||
## 📋 Dockerfile
|
||||
|
||||
### Build Stage
|
||||
|
||||
```dockerfile
|
||||
FROM golang:1.25.6-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# WebP için gerekli build dependencies
|
||||
RUN apk add --no-cache git gcc musl-dev libwebp-dev
|
||||
|
||||
COPY ../go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY .. .
|
||||
RUN go mod tidy
|
||||
|
||||
# Swagger
|
||||
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||
RUN swag init
|
||||
|
||||
# CGO enabled build with static linking
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -a \
|
||||
-ldflags '-linkmode external -extldflags "-static"' \
|
||||
-o main .
|
||||
```
|
||||
|
||||
### Runtime Stage
|
||||
```dockerfile
|
||||
FROM alpine:latest
|
||||
WORKDIR /app
|
||||
|
||||
# WebP runtime library + CA certificates
|
||||
RUN apk --no-cache add ca-certificates libwebp
|
||||
|
||||
COPY --from=builder /app/main .
|
||||
COPY --from=builder /app/.env .
|
||||
COPY --from=builder /app/web ./web
|
||||
COPY --from=builder /app/docs ./docs
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["./main"]
|
||||
```
|
||||
|
||||
## 🎯 Desteklenen Format'lar
|
||||
|
||||
| Format | Varsayılan | Kalite | Dosya Boyutu | CGO Gerekli |
|
||||
|--------|-----------|--------|--------------|-------------|
|
||||
| **WebP** | ✅ Evet | Ayarlanabilir (0-100) | En küçük | ✅ Evet |
|
||||
| JPEG | ❌ Hayır | Ayarlanabilir (1-100) | Orta | ❌ Hayır |
|
||||
| PNG | ❌ Hayır | Lossless | En büyük | ❌ Hayır |
|
||||
|
||||
## 📊 WebP Avantajları
|
||||
|
||||
### Dosya Boyutu Karşılaştırması
|
||||
```
|
||||
Aynı kalitede:
|
||||
- PNG: 100 KB
|
||||
- JPEG: 50 KB
|
||||
- WebP: 32 KB ✅ (~%35 daha küçük)
|
||||
```
|
||||
|
||||
### Browser Desteği
|
||||
- ✅ Chrome/Edge (tüm versiyonlar)
|
||||
- ✅ Firefox (tüm versiyonlar)
|
||||
- ✅ Safari 14+ (iOS 14+)
|
||||
- ✅ Opera (tüm versiyonlar)
|
||||
- ⚠️ IE11 (desteklenmez, fallback gerekebilir)
|
||||
|
||||
## 🔧 Environment Variables
|
||||
|
||||
### Avatar Settings
|
||||
```env
|
||||
AVATAR_H=150 # Height
|
||||
AVATAR_W=150 # Width
|
||||
AVATAR_Q=90 # Quality (0-100)
|
||||
AVATAR_B=cover # Mode (cover/contain/resize)
|
||||
AVATAR_F=webp # Format (webp/jpg/png)
|
||||
```
|
||||
|
||||
### Database (Dokploy Managed)
|
||||
```env
|
||||
DB_HOST=your-dokploy-postgres-host
|
||||
DB_PORT=5432
|
||||
DB_USER=postgres
|
||||
DB_PASSWORD=your_password
|
||||
DB_NAME=gauth
|
||||
```
|
||||
|
||||
### Redis (Dokploy Managed)
|
||||
```env
|
||||
REDIS_HOST=your-dokploy-redis-host
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=your_redis_password
|
||||
REDIS_USER=default
|
||||
```
|
||||
|
||||
## 🚀 Deployment Workflow
|
||||
|
||||
### 1. Dokploy'da Servisler Oluştur
|
||||
```
|
||||
1. PostgreSQL Database
|
||||
- Version: 15
|
||||
- Username: postgres
|
||||
- Password: [güçlü şifre]
|
||||
- Database: gauth
|
||||
|
||||
2. Redis Cache
|
||||
- Version: 7
|
||||
- Password: [güçlü şifre]
|
||||
- Max Memory: 256MB
|
||||
```
|
||||
|
||||
### 2. GitHub'a Push
|
||||
```bash
|
||||
git add .
|
||||
git commit -m "Production: WebP support + external DB/Redis"
|
||||
git push origin main
|
||||
```
|
||||
|
||||
### 3. Dokploy'da Deploy
|
||||
```
|
||||
1. New Project → GitHub
|
||||
2. Repository: your-repo
|
||||
3. Branch: main
|
||||
4. Build: Docker Compose
|
||||
5. File: docker-compose.prod.yml
|
||||
6. Environment Variables: (yukardaki tüm değişkenler)
|
||||
7. Deploy!
|
||||
```
|
||||
|
||||
### 4. İlk Admin Oluştur
|
||||
```bash
|
||||
# Container'a bağlan
|
||||
docker exec -it app_auth_central /app/main seed-admin
|
||||
|
||||
# Varsayılan:
|
||||
# Email: admin@gauth.local
|
||||
# Password: Admin@123
|
||||
```
|
||||
|
||||
## 🧪 Build Test
|
||||
|
||||
### Local Test
|
||||
```bash
|
||||
# WebP dependency
|
||||
go get github.com/chai2010/webp@latest
|
||||
go mod tidy
|
||||
|
||||
# Local build (macOS/Linux)
|
||||
go build -o main .
|
||||
|
||||
# Cross-compile for Linux
|
||||
CGO_ENABLED=1 GOOS=linux go build -o main .
|
||||
```
|
||||
|
||||
### Docker Test
|
||||
```bash
|
||||
# Build
|
||||
docker build -t authcentral .
|
||||
|
||||
# Run
|
||||
docker run -p 8080:8080 \
|
||||
-e DB_HOST=your-db-host \
|
||||
-e REDIS_HOST=your-redis-host \
|
||||
authcentral
|
||||
|
||||
# Test
|
||||
curl http://localhost:8080/
|
||||
```
|
||||
|
||||
## 📝 Notlar
|
||||
|
||||
### CGO Build
|
||||
- ⚠️ **Cross-compile sınırlaması**: CGO enabled olduğunda farklı OS'ler için compile etmek karmaşıktır
|
||||
- ✅ **Docker ile çözüm**: Docker builder her platformda Linux için build eder
|
||||
- ✅ **Static linking**: Binary portable, dependencies gömülü
|
||||
|
||||
### Production Checklist
|
||||
- [ ] Dokploy'da PostgreSQL oluşturuldu
|
||||
- [ ] Dokploy'da Redis oluşturuldu
|
||||
- [ ] Tüm environment variables ayarlandı
|
||||
- [ ] OAuth credentials (Google, GitHub) ayarlandı
|
||||
- [ ] Email SMTP ayarları yapıldı
|
||||
- [ ] Domain DNS ayarları yapıldı
|
||||
- [ ] SSL sertifikası aktif
|
||||
- [ ] İlk admin kullanıcı oluşturuldu
|
||||
- [ ] Avatar upload test edildi
|
||||
- [ ] WebP support test edildi
|
||||
|
||||
## 🎉 Sonuç
|
||||
|
||||
**AuthCentral WebP destekli ve Dokploy'a deploy için hazır!**
|
||||
|
||||
- ✅ WebP default format
|
||||
- ✅ CGO enabled build
|
||||
- ✅ Static linking
|
||||
- ✅ External PostgreSQL/Redis
|
||||
- ✅ Docker Compose production ready
|
||||
- ✅ Swagger documentation
|
||||
- ✅ Full API documentation
|
||||
|
||||
**Dosya boyutları ~%35 daha küçük!** 🚀
|
||||
Reference in New Issue
Block a user