services:
  web:
    build: .
    container_name: dw-quantumasis-web-completa-web
    labels:
      docker-web: "true"
      docker-web-project: "quantumasis-web-completa"
    ports:
      - "8080:80"
    volumes:
      - /Users/jordandiaz/Documents/GitHub/quantumasis-web-completa:/var/www/html
      - ./init.sh:/docker-entrypoint-init.d/init.sh
      - ./quantu_web2134-209-184-114-2-2619-49.sql:/docker-entrypoint-init.d/quantu_web2134-209-184-114-2-2619-49.sql
    environment:
      - DB_SERVER=${DB_SERVER}
      - DB_DATABASE=${DB_DATABASE}
      - DB_USERNAME=${DB_USERNAME}
      - DB_PASSWORD=${DB_PASSWORD}
    depends_on:
      db:
        condition: service_healthy
    command: >
      bash -c "chmod +x /docker-entrypoint-init.d/init.sh &&
               /docker-entrypoint-init.d/init.sh &&
               apache2-foreground"

  db:
    image: mariadb:10.11
    container_name: dw-quantumasis-web-completa-db
    labels:
      docker-web: "true"
      docker-web-project: "quantumasis-web-completa"
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "33060:3306"
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    container_name: dw-quantumasis-web-completa-redis
    labels:
      docker-web: "true"
      docker-web-project: "quantumasis-web-completa"
    restart: unless-stopped
    network_mode: "service:web"
    depends_on:
      - web
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 3
volumes:
  db_data:
