services:
  db:
    image: mariadb:10.11.18
    container_name: contabilidad_db
    restart: always
    environment:
      MARIADB_DATABASE: fonjupad_db
      MARIADB_USER: contabilidad_user
      MARIADB_PASSWORD: contabilidad_password
      MARIADB_ROOT_PASSWORD: root_password
    ports:
      - "3306:3306"
    volumes:
      - mariadb_data:/var/lib/mysql

  web:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: contabilidad_web
    restart: always
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/app
    ports:
      - "8000:8000"
    environment:
      - DB_ENGINE=django.db.backends.mysql
      - DB_NAME=fonjupad_db
      - DB_USER=contabilidad_user
      - DB_PASSWORD=contabilidad_password
      - DB_HOST=contabilidad_db
      - DB_PORT=3306
    depends_on:
      - db

volumes:
  mariadb_data:
