services:
  iiko-db:
    image: mariadb:12.2.2
    container_name: iiko-db
    restart: unless-stopped
    user: "1000:1000"
    environment:
      PGID: 1000
      PUID: 1000
      MARIADB_ROOT_PASSWORD: DVjXT_kew508
      MARIADB_DATABASE: app_db
      MARIADB_USER: app_user
      MARIADB_PASSWORD: app_pass
      TZ: Europe/Moscow
    #    ports:
    #      - "3306:3306"
    volumes:
      - $PWD/app/mariadb:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

  iiko-pma:
    image: phpmyadmin:5.2.3
    container_name: iiko-pma
    depends_on:
      iiko-db:
        condition: service_healthy
    restart: unless-stopped
    environment:
      PMA_HOST: iiko-db
      PMA_PORT: 3306
      UPLOAD_LIMIT: 10M
      # PMA_ABSOLUTE_URI: https://phpmyadmin.dev.xserver.su/
      TZ: Europe/Moscow
    ports:
      - "7102:80"

  iiko-redis:
    image: redis:latest
    container_name: iiko-redis
    restart: unless-stopped
    user: "1000:1000"
    environment:
      PGID: 1000
      PUID: 1000
      TZ: Europe/Moscow
    #    ports:
    #      - "6379:6379"
    volumes:
      - $PWD/app/redis:/data
      - /etc/localtime:/etc/localtime:ro

  iiko-app:
    build: .
    container_name: iiko-app
    restart: unless-stopped
    ports:
      - "7104:7104"
    depends_on:
      iiko-db:
        condition: service_healthy
      iiko-redis:
        condition: service_started
    environment:
      DATABASE__HOST: iiko-db
      DATABASE__PORT: 3306
      DATABASE__DATABASE: app_db
      DATABASE__USER: app_user
      DATABASE__PASSWORD: app_pass
      REDIS__HOST: iiko-redis
      REDIS__PORT: 6379
      SERVER__PORT: 7104
    volumes:
      - $PWD/app/logs:/app/logs
