version: "3.9"

services:
  frontend:
    build:
      context: ./fuse-starter-v20.0.0
    container_name: vending-frontend
    ports:
      - "8086:80"
    depends_on:
      - backend
    restart: always

  backend:
    build:
      context: ./Machine-Backend
    container_name: vending-backend
    env_file:
      - ./Machine-Backend/.env
    ports:
      - "8087:5000"
    volumes:
      - ./Machine-Backend:/app
    depends_on:
      - db
    restart: always
    command: >
      sh -c "python seed_user.py && gunicorn --bind 0.0.0.0:5000 run:app"

  db:
    image: mysql:8.0
    container_name: vending-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootpass
      MYSQL_DATABASE: vending
      MYSQL_USER: vendinguser
      MYSQL_PASSWORD: vendingpass
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql

volumes:
  mysql_data:
