services:
  flask:
    image: flask
    build:
      context: .
      dockerfile: Dockerfile
    stop_signal: SIGINT
    ports:
      - '5000:5000'
    depends_on:
      - database
    networks:
      - network
    environment:
      DEVELOPMENT_MODE: ${DEVELOPMENT_MODE}
      DATABASE_HOST: ${DATABASE_HOST}
      DATABASE_USER: ${DATABASE_USER}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      DATABASE_NAME: ${DATABASE_NAME}
      SECRET_KEY: ${SECRET_KEY}
      FLASK_APP: app/__init__.py
    command: ["flask", "run", "--host=0.0.0.0", "--port=5000"]
  database:
    image: mysql:8.0
    ports:
      - '3306:3306'
    environment:
      MYSQL_ROOT_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_USER: ${DATABASE_USER}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - network

volumes:
  mysql_data:

networks:
  network:
    driver: bridge
