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

  #MySQL Service
  inverted_line_db:
    image: mysql:5.7
    container_name: inverted_line_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:
      - inverted_line_mysql_data:/var/lib/mysql
    networks:
      - inverted_line_network

  #Nginx Service
  inverted_line_nginx:
    image: nginx:alpine
    container_name: inverted_line_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:
      - inverted_line_network
  # phpmyadmin service
  inverted_line_phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: unless-stopped
    container_name: inverted_line_phpmyadmin
    depends_on:
      - inverted_line_db
    ports:
      - "${DOCKER_PHPMYADMIN_PORT}:80"
    environment:
      PMA_HOST: inverted_line_db
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
    networks:
      - inverted_line_network

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

#Docker Networks
networks:
  inverted_line_network:
    driver: bridge

#Volumes
volumes:
  inverted_line_mysql_data:
  inverted_line_cache:
