version: '3.8'

services:
  app:
    restart: unless-stopped
    build:
      context: .
    ports:
      - 8000:8000
    volumes:
      - ./:/app
    networks:
      - housewars
    environment:
      DJANGO_SETTINGS_MODULE: "CollegiateHouseWars.settings.docker"
    depends_on:
      mysqldb:
        condition: service_healthy
    command: >
      bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
  mysqldb:
    restart: unless-stopped
    image: mysql:5.7
    ports:
      - 3306:3306
    volumes:
      - housewars-mysql:/var/lib/mysql
    networks:
      - housewars
    environment:
      MYSQL_ROOT_PASSWORD: "passw0rd"
      MYSQL_DATABASE: dev
    healthcheck:
      test: [ "CMD", "mysqladmin", "ping", "-h", "localhost" ]
      timeout: 5s
      retries: 10
volumes:
  housewars-mysql:
networks:
  housewars: {}
