version: '3.8'

services:
  app:
    build: .
    ports:
      - "80:80"
      - "8443:8443"
      - "22345:22345"
    environment:
      - SPRING_DATASOURCE_URL=jdbc:mariadb://db:3306/main
      - SPRING_DATASOURCE_USERNAME=cat
      - SPRING_DATASOURCE_PASSWORD=meow
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.mariadb.jdbc.Driver
    depends_on:
      - db
    volumes:
      - ./config:/app/config
      - ./data:/app/data

  db:
    image: mariadb:latest
    environment:
      MYSQL_ROOT_PASSWORD: meow
      MYSQL_DATABASE: main
      MYSQL_USER: cat
      MYSQL_PASSWORD: meow
    ports:
      - "127.0.0.1:3369:3306"
    # There is an unfixed bug in Windows WSL2 that prevents volumes from working
    # properly with mariadb. Please uncomment this on Linux / MacOS.
    # Check https://stackoverflow.com/questions/76711550/i-get-an-error-on-mariadb-allways-i-start-my-app
    # volumes:
      # - ./data/db:/var/lib/mysql
