version: "3.7"
services:
  #PHP Service
  lv_bdeduline:
    build:
      args:
        user: ahrasel
        uid: 1000
      context: .
      dockerfile: .docker/Dockerfile
    image: lv_bdeduline
    restart: unless-stopped
    working_dir: /var/www/
    tty: true
    environment:
      SERVICE_NAME: app
      SERVICE_TAGS: dev
    volumes:
      - ./:/var/www
      - ./.docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - lv_bdeduline_network

  #MySQL Service
  lv_bdeduline_db:
    image: mysql:8.0
    container_name: lv_bdeduline_db
    restart: unless-stopped
    ports:
      - "${DOCKER_DB_PORT}:3306"
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_USER: ${DB_USERNAME}
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - lv_bdeduline_mysql_data:/var/lib/mysql
    networks:
      - lv_bdeduline_network

  #Nginx Service
  lv_bdeduline_nginx:
    image: nginx:alpine
    container_name: lv_bdeduline_nginx
    restart: unless-stopped
    tty: true
    ports:
      - "${DOCKER_APP_PORT}:80"
      - "${DOCKER_APP_SSL_PORT}:443"
    volumes:
      - ./:/var/www
      - ./.docker/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - lv_bdeduline_network
  # phpmyadmin service
  lv_bdeduline_phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: unless-stopped
    container_name: lv_bdeduline_phpmyadmin
    depends_on:
      - lv_bdeduline_db
    ports:
      - "${DOCKER_PHPMYADMIN_PORT}:80"
    environment:
      PMA_HOST: lv_bdeduline_db
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
    networks:
      - lv_bdeduline_network

  lv_bdeduline_redis_cache:
    image: redis:alpine
    restart: always
    container_name: lv_bdeduline_redis_cache
    ports:
      - '${DOCKER_REDIS_PORT}:6379'
    command: redis-server --save 20 1 --loglevel warning --requirepass ${REDIS_PASSWORD}
    volumes:
      - lv_bdeduline_cache:/data
    networks:
    - lv_bdeduline_network

#Docker Networks
networks:
  lv_bdeduline_network:
    driver: bridge

#Volumes
volumes:
  lv_bdeduline_mysql_data:
  lv_bdeduline_cache:
