version: '3.8'

services:
  web:
    build: .
    ports:
      - "5000:5000"
    depends_on:
      - db
    restart: always
    environment:
      # Environment variables for connecting to the database
      MYSQL_HOST: db
      MYSQL_USER: "root"
      MYSQL_PASSWORD: "example"
      MYSQL_DATABASE: "exampledb"
    networks:
      - app-network

  db:
    image: mysql:8.0
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "example"
      MYSQL_DATABASE: "exampledb"
    volumes:
      - db_data:/var/lib/mysql
    ports:
      - "3306:3306"
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

volumes:
  db_data:
