# Lab 03: Compute & EC2 - Docker Compose Configuration # Simula diverse EC2 instance types usando resource limits Docker version: "3.8" services: # Web Server - simula t2.micro (1 vCPU, 1 GB RAM) web: image: nginx:alpine container_name: lab03-web hostname: web deploy: resources: limits: cpus: '1' memory: 1G healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"] interval: 10s timeout: 5s retries: 3 start_period: 5s ports: - "127.0.0.1:8080:80" depends_on: app: condition: service_healthy restart: unless-stopped # Application Server - simula t2.small (1 vCPU, 2 GB RAM) app: image: nginx:alpine container_name: lab03-app hostname: app deploy: resources: limits: cpus: '1' memory: 2G healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/"] interval: 10s timeout: 5s retries: 3 start_period: 5s ports: - "127.0.0.1:8081:80" depends_on: db: condition: service_healthy restart: unless-stopped # Worker - simula t2.medium (2 vCPU, 4 GB RAM) worker: image: alpine:3.19 container_name: lab03-worker hostname: worker command: ["sh", "-c", "sleep 3600"] deploy: resources: limits: cpus: '2' memory: 4G healthcheck: test: ["CMD-SHELL", "exit 0"] interval: 30s timeout: 5s retries: 3 restart: unless-stopped # Database - simula t2.medium (2 vCPU, 4 GB RAM) db: image: postgres:16-alpine container_name: lab03-db hostname: db environment: POSTGRES_DB: lab03_db POSTGRES_USER: lab03_user POSTGRES_PASSWORD: lab03_password POSTGRES_INITDB_ARGS: "-E UTF8" deploy: resources: limits: cpus: '2' memory: 4G healthcheck: test: ["CMD-SHELL", "pg_isready -U lab03_user -d lab03_db || exit 1"] interval: 10s timeout: 5s retries: 5 start_period: 10s volumes: - db-data:/var/lib/postgresql/data restart: unless-stopped # Stress Test Container - per verifica enforcement stress-test: image: alpine:3.19 container_name: lab03-stress hostname: stress-test command: ["sh", "-c", "sleep 3600"] deploy: resources: limits: cpus: '0.5' memory: 512M healthcheck: test: ["CMD-SHELL", "exit 0"] interval: 5s timeout: 3s retries: 3 restart: unless-stopped # Persistent Volumes volumes: db-data: driver: local