version: "3.8"
services:
  vakil_db:
    container_name: vakil_db
    image: mariadb:10.11
    restart: always
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - mariadb_data:/var/lib/mysql
    ports:
      - "3310:3306"
    networks:
      - app_network

  vakil_backend:
    container_name: vakil_backend
    build:
      context: .
      dockerfile: ./docker/php/Dockerfile
    expose:
      - 9000
    volumes:
      - .:/usr/src/app
      - /usr/src/app/vendor/
    depends_on:
      - vakil_db
    networks:
      - app_network

  vakil_nginx:
    container_name: vakil_nginx
    build:
      context: .
      dockerfile: ./docker/nginx/Dockerfile
    volumes:
      - ./storage:/usr/src/app/storage
      - ./public:/usr/src/app/public
    ports:
      - "8004:80"
    depends_on:
      - vakil_backend
    environment:
      NGINX_FPM_HOST: vakil_backend
      NGINX_ROOT: /usr/src/app/public
    command: ln -s /usr/src/app/storage/app/public /usr/src/app/public/storage
    networks:
      - app_network

  vakil_redis:
    container_name: vakil_redis
    image: redis:latest
    ports:
      - "6383:6379"
    networks:
      - app_network

volumes:
  mariadb_data:

networks:
  app_network:
    driver: bridge
