services:

  php:
    build:
      context: .
      dockerfile: Dockerfile
    image: php_una:latest  # This names the local image
    pull_policy: build     # Instructs Compose to build if missing, not pull
    environment:
      APACHE_DOCUMENT_ROOT: "/var/www/public"
      PHP_ERROR_LOG: "/var/www/public/logs/php.log"
    ports:
      - "80:8080"
      - "443:8443"
    volumes:
      - ".:/var/www"
    depends_on:
      - mysql
      - php_cron
    extra_hosts:
      - "${APP_DOCKER_HOST}:host-gateway"
    networks:
      - unacmsnet

  php_cron:
    image: php_una
    environment:
      PHP_ERROR_LOG: "/var/www/public/logs/php_cron.log"
    user: root # required for cron
    command: [ "cron","-f" ]
    depends_on:
      - mysql
    extra_hosts:
      - "${APP_DOCKER_HOST}:host-gateway"
    networks:
      - unacmsnet

  mysql:
    image: mariadb:11.4
    environment:
      MYSQL_ROOT_PASSWORD: 'root'
      MYSQL_USER: 'una'
      MYSQL_PASSWORD: 'una'
      MYSQL_DATABASE: 'una'
    command: # enable bin log
      --log-bin=log_bin_file
      --binlog-format=MIXED
    volumes:
      - "mysqldata:/var/lib/mysql"
      - "./docker/config/mysqld.cnf:/etc/mysql/conf.d/mysqld.cnf"
      - "./docker/dumps:/docker-entrypoint-initdb.d:ro"
    ports:
      - "3306:3306"
    networks:
      - unacmsnet

  mailpit:
    image: axllent/mailpit
    restart: unless-stopped
    ports:
      - "8025:8025"
    environment:
      MP_MAX_MESSAGES: 5000
      MP_SMTP_AUTH_ACCEPT_ANY: 1
      MP_SMTP_AUTH_ALLOW_INSECURE: 1
    networks:
      - unacmsnet

  node:
    image: node:22-alpine
    volumes:
      - ".:/var/www"
    working_dir: "/var/www"
    entrypoint: [ "/bin/sh", "-c", "corepack enable yarn && exec \"$@\"", "--" ]
    environment:
      COREPACK_ENABLE_DOWNLOAD_PROMPT: 0
      COREPACK_ENABLE_AUTO_PIN: 0
    networks:
      - unacmsnet

networks:
  unacmsnet:
    driver: bridge
volumes:
  mysqldata: