version: '3'
services:
  db:
    image: mariadb
    restart: always
    environment:
      - MYSQL_DATABASE=tomboladb
      - MYSQL_USER=fmr
      - MYSQL_PASSWORD=fmr
      - MYSQL_ROOT_PASSWORD=fmr
    ports:
      - "3306:3306"    
    networks:
      - backend
    volumes:
      - data:/var/lib/mysql 
    healthcheck:
      interval: 30s
      retries: 3
      test:
        [
          "CMD",
          "healthcheck.sh",
          "--su-mysql",
          "--connect",
          "--innodb_initialized"
        ]
      timeout: 30s

  webserver:
    build: .
    ports:
      - 80:80
      - 443:443
    volumes:      
      - dump:/var/www/html/dumps
      - migrations_data:/var/www/html/tombola/migrations
      - ssl_cert:/etc/letsencrypt
    depends_on:
      db:
        condition: service_healthy
    networks:
      - backend
    

volumes:
  data:
  latexvar:
  pgaconfig:
  dump:
  migrations_data:
  ssl_cert:

networks:
  backend:
