version: '3.8'

services:
  # The PHP Server
  robot-server:
    build: .
    container_name: robot-server-container
    ports:
      - "8088:80"  # Exposed on Port 8081
    volumes:
      - ./api:/var/www/html/api
    depends_on:
      - robot-db
    networks:
      - shared-network

  # The Database (MariaDB)
  robot-db:
    image: mariadb:10.5
    container_name: robot-db-container
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: pi_tasks
      MYSQL_USER: pi_user
      MYSQL_PASSWORD: your_strong_password
    ports:
      - "3308:3306" # Exposed on Port 3307
    volumes:
      - robot_db_data:/var/lib/mysql
      # Automatically run the SQL script on first startup:
      - ./db_init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - shared-network

volumes:
  robot_db_data:

networks:
  shared-network:
    external: true