version: "3.9"
services:
  #PHP Service
  fintrack:
    build:
      args:
        user: ahrasel
        uid: 1000
      context: .
      dockerfile: .docker/Dockerfile
    image: fintrack
    container_name: fintrack
    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:
      - fintrack_network

  #MySQL Service
  fintrack_db:
    image: mysql:8.0
    container_name: fintrack_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:
      - fintrack_mysql_data:/var/lib/mysql
    networks:
      - fintrack_network

  #Nginx Service
  fintrack_nginx:
    image: nginx:alpine
    container_name: fintrack_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:
      - fintrack_network
  # phpmyadmin service
  fintrack_phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: unless-stopped
    container_name: fintrack_phpmyadmin
    depends_on:
      - fintrack_db
    ports:
      - "${DOCKER_PHPMYADMIN_PORT}:80"
    environment:
      PMA_HOST: fintrack_db
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      UPLOAD_LIMIT: 50M
    networks:
      - fintrack_network

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

#Docker Networks
networks:
  fintrack_network:
    driver: bridge

#Volumes
volumes:
  fintrack_mysql_data:
  fintrack_cache:
