first commit
This commit is contained in:
54
DOCKER.md
Normal file
54
DOCKER.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Docker (Next.js + NextAuth)
|
||||
|
||||
Bu repo **Node.js 24.12.0** ve **Yarn 1.22.22** ile Dockerize edilmiştir.
|
||||
|
||||
## Gereksinimler
|
||||
|
||||
- Docker Desktop
|
||||
|
||||
## Ortam Değişkenleri (ENV)
|
||||
|
||||
Repo kökünde `.env.local` oluşturun:
|
||||
|
||||
- Örnek: `env.example.txt`
|
||||
- Kritik değişkenler:
|
||||
- `NEXTAUTH_URL`
|
||||
- `NEXTAUTH_SECRET`
|
||||
- `NEXT_PUBLIC_API_BASE_URL`
|
||||
|
||||
> Not: `.env*` dosyaları `.dockerignore` ile image içine kopyalanmaz. Compose veya `--env-file` ile verilir.
|
||||
|
||||
## Prod (multi-stage)
|
||||
|
||||
Image build:
|
||||
|
||||
```bash
|
||||
docker build -t next-dj:prod --target runner .
|
||||
```
|
||||
|
||||
Container run:
|
||||
|
||||
```bash
|
||||
docker run --rm -p 3000:3000 --env-file .env.local next-dj:prod
|
||||
```
|
||||
|
||||
## Dev (hot reload)
|
||||
|
||||
```bash
|
||||
docker compose up --build web-dev
|
||||
```
|
||||
|
||||
- Kod değişiklikleri otomatik yansır.
|
||||
- `node_modules` ve `.next` cache için named volume kullanılır.
|
||||
|
||||
## Compose ile prod
|
||||
|
||||
```bash
|
||||
docker compose up --build web-prod
|
||||
```
|
||||
|
||||
## Sık karşılaşılabilecek sorunlar
|
||||
|
||||
- **Backend URL**: Docker içinde `NEXT_PUBLIC_API_BASE_URL`, `localhost` yerine container ağından erişilebilir bir host olmalı.
|
||||
- Backend de compose'ta ise çoğunlukla: `http://backend:8000/api/v1`
|
||||
- **NEXTAUTH_URL**: Prod'da gerçek domaininizi yazın.
|
||||
Reference in New Issue
Block a user