# Image Service - AWS Elastic Beanstalk Edition

Deployment-ready Puppeteer Image Service für AWS Elastic Beanstalk.

## 📁 Projektstruktur

```
backend-image-service/
├── image-service/
│   ├── server.js                      # Express Server mit Puppeteer
│   ├── package.json                   # Node.js Dependencies
│   ├── Dockerfile                     # Docker Image
│   ├── Dockerrun.aws.json            # EB Docker Configuration ✨
│   ├── .ebextensions/                # EB Environment Config ✨
│   │   ├── 01_environment.config     # Instance & Health Checks
│   │   ├── 02_cloudwatch.config      # Logging
│   │   └── 03_resources.config       # Deployment & Resources
│   ├── .ebignore                     # EB Deployment Ignore
│   └── .dockerignore                 # Docker Build Ignore
│
├── init-eb-environment.sh            # Erstmaliges EB Setup ✨
├── deploy-to-eb.sh                   # Deployment Script ✨
├── test-image.sh                # Test Script
│
├── EB_QUICKSTART.md                  # 10-Min Quick Start ✨
├── ELASTIC_BEANSTALK_DEPLOYMENT.md   # Vollständige EB Docs ✨
├── README.md                         # Allgemeine Dokumentation
└── QUICKSTART.md                     # Lokaler Quick Start
```

## 🚀 Deployment Optionen

### Option 1: Automatisches EB Deployment (Empfohlen)

```bash
# 1. Setup (nur einmal)
./init-eb-environment.sh image-service-prod

# 2. Updates deployen
./deploy-to-eb.sh image-service-prod
```

### Option 2: Lokales Development

```bash
# Docker Compose
docker-compose up -d

# Oder lokal
cd image-service
npm install
npm start
```

### Option 3: Kubernetes

```bash
kubectl apply -f kubernetes/
```

## 📋 Elastic Beanstalk Features

✅ **Automatische Konfiguration:**
- Load Balancer (Application LB)
- Auto-Scaling (1-4 Instances)
- Health Checks auf `/health`
- CloudWatch Logging
- Rolling Deployments

✅ **Production-Ready:**
- t3.medium Instances (2 vCPU, 4 GB RAM)
- Docker Container Isolation
- Automatic Restart on Failure
- Zero-Downtime Deployments

✅ **Monitoring:**
- CloudWatch Logs (7 Tage Retention)
- EB Health Dashboard
- Instance Metrics (CPU, Memory, Network)

## 💰 Kosten Übersicht

| Umgebung | Instances | Type | Kosten/Monat |
|----------|-----------|------|--------------|
| Dev | 1 | t3.medium | ~$50-60 |
| Prod (Low) | 1-2 | t3.medium | ~$70-90 |
| Prod (High) | 2-4 | t3.medium | ~$90-160 |

Mit Spot Instances: ~70% günstiger

## 🎯 Quick Commands

```bash
# Status
eb status

# Logs
eb logs --stream

# Scale
eb scale 4

# Restart
eb restart

# SSH
eb ssh

# Terminate
eb terminate image-service-prod
```

## 📚 Dokumentation

1. **[EB_QUICKSTART.md](EB_QUICKSTART.md)** - 10 Minuten Quick Start
2. **[ELASTIC_BEANSTALK_DEPLOYMENT.md](ELASTIC_BEANSTALK_DEPLOYMENT.md)** - Vollständige EB Docs
3. **[README.md](README.md)** - Allgemeine Service Dokumentation
4. **[QUICKSTART.md](QUICKSTART.md)** - Lokale Entwicklung

## 🔧 Konfiguration

### Environment Variables

In `.ebextensions/01_environment.config` oder via:
```bash
eb setenv NODE_ENV=production PORT=3000
```

### Instance Type ändern

```bash
eb scale 2 --instance-type t3.large
```

### Auto-Scaling Limits

In `.ebextensions/01_environment.config`:
```yaml
aws:autoscaling:asg:
  MinSize: 1
  MaxSize: 4
```

## 🧪 Testing

```bash
# Lokal testen
./test-image.sh

# EB Environment testen
./test-image.sh http://your-env.elasticbeanstalk.com
```

## 🆘 Support

**Team:** buildnext GmbH
**Projekt:** Releasebird Image Service
**AWS Region:** eu-central-1 (default)

### Troubleshooting

Siehe [ELASTIC_BEANSTALK_DEPLOYMENT.md](ELASTIC_BEANSTALK_DEPLOYMENT.md) Abschnitt "Troubleshooting"

---

## 📝 Was ist neu?

**Elastic Beanstalk Support:**
- ✨ `Dockerrun.aws.json` - EB Docker Config
- ✨ `.ebextensions/` - Environment Konfiguration
- ✨ `init-eb-environment.sh` - Setup Script
- ✨ `deploy-to-eb.sh` - Deployment Script
- ✨ Vollständige EB Dokumentation

**Alle bestehenden Features bleiben erhalten:**
- ✅ Docker & Docker Compose
- ✅ Kubernetes Manifests
- ✅ Lokale Entwicklung
- ✅ Spring Boot Integration

---

🎉 **Ready for AWS Elastic Beanstalk!**
