version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: servicepulse_backend
    restart: unless-stopped
    volumes:
      - .:/var/www
      - ./storage:/var/www/storage
    depends_on:
      - mysql
      - redis
    networks:
      - servicepulse
    environment:
      - APP_ENV=production
      - DB_HOST=mysql
      - REDIS_HOST=redis

  nginx:
    image: nginx:alpine
    container_name: servicepulse_nginx
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - .:/var/www
      - ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - app
    networks:
      - servicepulse

  mysql:
    image: mysql:8.0
    container_name: servicepulse_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - servicepulse

  redis:
    image: redis:alpine
    container_name: servicepulse_redis
    restart: unless-stopped
    networks:
      - servicepulse

networks:
  servicepulse:
    driver: bridge

volumes:
  mysql_data:
