services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    image: mtwu-app
    container_name: mtwu-app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
    networks:
      - mtwu-network
    depends_on:
      - db
      - redis

  nginx:
    image: nginx:alpine
    container_name: mtwu-nginx
    restart: unless-stopped
    ports:
      - "8000:80"
    volumes:
      - ./:/var/www
      - ./nginx/conf.d:/etc/nginx/conf.d
    networks:
      - mtwu-network
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: mtwu-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-mtwu_db}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-root}
      MYSQL_PASSWORD: ${DB_PASSWORD:-root}
      MYSQL_USER: ${DB_USERNAME:-mtwu}
      SERVICE_TAGS: dev
      SERVICE_NAME: mysql
    volumes:
      - dbdata:/var/lib/mysql
    networks:
      - mtwu-network

  redis:
    image: redis:alpine
    container_name: mtwu-redis
    restart: unless-stopped
    networks:
      - mtwu-network
    volumes: 
      - redisdata:/data

networks:
  mtwu-network:
    driver: bridge

volumes:
  dbdata:
    driver: local
  redisdata:
    driver: local
