version: "3.7"

services:
  app:
    build:
      context: ./
      dockerfile: Dockerfile
    image: accounting-application
    platform: linux/amd64
    container_name: accounting-application-app
    restart: unless-stopped
    working_dir: /var/www/
    networks:
      - accounting-application
    volumes:
      - ./:/var/www
      - ./php.ini:/usr/local/etc/php/conf.d/php.ini

  db:
    image: mysql:8.0
    platform: linux/amd64
    container_name: accounting-application-db
    restart: unless-stopped
    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:
      - ./docker-compose/mysql-new:/var/lib/mysql
    networks:
      - accounting-application

  nginx:
    image: nginx:1.17-alpine
    platform: linux/amd64
    container_name: accounting-application-nginx
    restart: unless-stopped
    ports:
      - 8000:80
    volumes:
      - ./:/var/www
      - ./nginx:/etc/nginx/conf.d/
    networks:
      - accounting-application
    depends_on:
      - app

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    platform: linux/amd64
    restart: unless-stopped
    container_name: phpmyadmin
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      UPLOAD_LIMIT: 200M
    ports:
      - 8080:80
    depends_on:
      - db
    networks:
      - accounting-application
  
  redis:
    image: redis:latest
    platform: linux/amd64
    container_name: accounting-application-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - ./docker-compose/redis-data:/data
    networks:
      - accounting-application


networks:
  accounting-application:
    driver: bridge
    