163 lines
4.5 KiB
YAML
163 lines
4.5 KiB
YAML
# Production Docker Compose för recipe-app + import-service
|
|
#
|
|
# Denna konfiguration:
|
|
# - Körs med diagram som visat i Caddyfile.production
|
|
# - Integrerar recipe-app (frontend + backend) + import-service
|
|
# - Använder MariaDB databas
|
|
# - Caddy som reverse proxy
|
|
#
|
|
# Usage:
|
|
# docker-compose -f docker-compose.production.yml up -d
|
|
#
|
|
# Anpassningar:
|
|
# - Uppdatera MYSQL_ROOT_PASSWORD och MYSQL_PASSWORD
|
|
# - Uppdatera DATABASE_URL för backend
|
|
# - Säkerställ att alla services kan nå varandra via docker-network
|
|
|
|
version: '3.8'
|
|
|
|
services:
|
|
# ============================================
|
|
# Frontend: Next.js 16.2
|
|
# ============================================
|
|
recipe-frontend:
|
|
build:
|
|
context: ./recipe-app/frontend
|
|
dockerfile: Dockerfile
|
|
container_name: recipe-frontend
|
|
environment:
|
|
- NODE_ENV=production
|
|
- NEXT_PUBLIC_API_URL=https://recept.gynther.se/api
|
|
networks:
|
|
- recipe-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# ============================================
|
|
# Backend: NestJS 10.3 + Prisma
|
|
# ============================================
|
|
recipe-api:
|
|
build:
|
|
context: ./recipe-app/backend
|
|
dockerfile: Dockerfile
|
|
container_name: recipe-api
|
|
depends_on:
|
|
recipe-db:
|
|
condition: service_healthy
|
|
recipe-import-service:
|
|
condition: service_healthy
|
|
environment:
|
|
- NODE_ENV=production
|
|
- PORT=8080
|
|
- DATABASE_URL=mysql://recipe_user:${DB_PASSWORD:-secure_password}@recipe-db:3306/recipe_db?schema=public
|
|
- IMPORT_SERVICE_URL=http://recipe-import-service:3000
|
|
- LOG_LEVEL=info
|
|
networks:
|
|
- recipe-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# ============================================
|
|
# Database: MariaDB 11
|
|
# ============================================
|
|
recipe-db:
|
|
image: mariadb:11
|
|
container_name: recipe-db
|
|
environment:
|
|
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-root_password}
|
|
- MYSQL_DATABASE=recipe_db
|
|
- MYSQL_USER=recipe_user
|
|
- MYSQL_PASSWORD=${DB_PASSWORD:-secure_password}
|
|
- MYSQL_INITDB_SKIP_TZINFO=1
|
|
volumes:
|
|
- recipe-db-data:/var/lib/mysql
|
|
networks:
|
|
- recipe-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# ============================================
|
|
# Import Service: Document Converter (NestJS)
|
|
# ============================================
|
|
recipe-import-service:
|
|
build:
|
|
context: ./recipe-document-converter/recipe-document-converter
|
|
dockerfile: Dockerfile
|
|
container_name: recipe-import-service
|
|
environment:
|
|
- NODE_ENV=production
|
|
- PORT=3000
|
|
- LOG_LEVEL=info
|
|
- MAX_FILE_SIZE=50000000
|
|
volumes:
|
|
- recipe-imports-data:/app/uploads
|
|
networks:
|
|
- recipe-network
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:3000/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 40s
|
|
|
|
# ============================================
|
|
# Reverse Proxy: Caddy 2.x
|
|
# ============================================
|
|
caddy:
|
|
image: caddy:2.7
|
|
container_name: caddy-proxy
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./Caddyfile.production:/etc/caddy/Caddyfile:ro
|
|
- caddy-data:/data
|
|
- caddy-config:/config
|
|
networks:
|
|
- recipe-network
|
|
depends_on:
|
|
- recipe-frontend
|
|
- recipe-api
|
|
- recipe-import-service
|
|
restart: unless-stopped
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
# ============================================
|
|
# Networks
|
|
# ============================================
|
|
networks:
|
|
recipe-network:
|
|
driver: bridge
|
|
|
|
# ============================================
|
|
# Volumes
|
|
# ============================================
|
|
volumes:
|
|
recipe-db-data:
|
|
driver: local
|
|
recipe-imports-data:
|
|
driver: local
|
|
caddy-data:
|
|
driver: local
|
|
caddy-config:
|
|
driver: local
|