version: "3.9"

services:
  app:
    build:
      context: .
      dockerfile: docker/Dockerfile
    container_name: laco_app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
    depends_on:
      - mysql
    networks:
      - laco

  nginx:
    image: nginx:1.25-alpine
    container_name: laco_nginx
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - app
    networks:
      - laco

  mysql:
    image: mysql:8.0
    container_name: laco_mysql
    restart: unless-stopped
    ports:
      - "3306:3306"
    environment:
      MYSQL_DATABASE: laco
      MYSQL_USER: laco
      MYSQL_PASSWORD: secret
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - laco

  redis:
    image: redis:7-alpine
    container_name: laco_redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    networks:
      - laco

  npm:
    image: node:20-alpine
    container_name: laco_node
    working_dir: /var/www
    volumes:
      - ./:/var/www
    command: sh -c "npm install && npm run dev"
    ports:
      - "5173:5173"
    networks:
      - laco

  composer:
    image: composer:2
    container_name: laco_composer
    working_dir: /var/www
    volumes:
      - ./:/var/www
    networks:
      - laco

networks:
  laco:
    driver: bridge

volumes:
  mysql_data: