# Use root/example as user/password credentials
# 
# to run: docker compose up
services:

  sql:
    labels:
      wheels.description: "Download and assemble the SQL data"
    container_name: sql_dump
    build: ./sql
    tty: false
    volumes:
      - type: volume
        source: sql_dump
        target: /docker-entrypoint-initdb.d
        read_only: true

  db:
    image: mariadb
    labels:
      net.defacto2.description: "Defacto2 database"
    restart: always
    container_name: database
    # expose ports to the other containers and the network
    ports:
      - 3306:3306
    networks:
      - back-tier
    volumes:
      # store the database on a docker volume
      - mysql:/var/lib/mysql
      # create the database on the first time build
      - type: volume
        source: sql_dump
        target: /docker-entrypoint-initdb.d
        read_only: false # must be kept to false!
    environment:
      # for more options, see: https://hub.docker.com/_/mariadb
      MARIADB_ROOT_PASSWORD: example
      MARIADB_DATABASE: defacto2-inno
      MARIADB_AUTO_UPGRADE: true
    depends_on:
      - sql

  adminer:
    labels:
      net.defacto2.description: "Admin web interface"
    image: adminer
    restart: always
    container_name: web_admin
    networks:
      - back-tier
    ports:
      - 8080:8080

networks:
  back-tier: {}

volumes:
  mysql:
  sql_dump: