services:
  nginx:
    image: nginx
    restart: always
    volumes:
      - ${PROJECTS_DIR}:/usr/share/nginx/html
      - ${PYTHON_PROJECTS_DIR}:/usr/share/nginx/python
      - ./config/nginx/conf.d:/etc/nginx/conf.d
      - ./config/nginx/includes.d:/etc/nginx/includes.d
      - ./config/nginx/ssl.d:/etc/nginx/ssl.d
      - ./log/nginx:/var/log/nginx
    ports:
      - "80:80"
      - "443:443"
  php:
    build:
      context: ./dockerfiles/php-fpm
      args:
        - CUSTOM_TZ=${CUSTOM_TZ}
        - CUSTOM_LOCALE=${CUSTOM_LOCALE}
        - CUSTOM_PUID=${WORKSPACE_PUID}
        - CUSTOM_PGID=${WORKSPACE_PGID}
        - PHP_OPT_MEMORY_LIMIT=${PHP_OPT_MEMORY_LIMIT}
        - PHP_OPT_POST_MAX_SIZE=${PHP_OPT_POST_MAX_SIZE}
        - PHP_OPT_UPLOAD_MAX_FILESIZE=${PHP_OPT_UPLOAD_MAX_FILESIZE}
        - PHP_OPT_MAX_EXECUTION_TIME=${PHP_OPT_MAX_EXECUTION_TIME}
# Other args that might be used for customize in every separate container
#        - INSTALL_PEAR_MAIL=true
#        - INSTALL_LIBREOFFICE=true
#        - INSTALL_NUC_CERTS=true
#        - PHP_OPT_SHORT_OPEN_TAG=On
    restart: always
    volumes:
      - ${PROJECTS_DIR}:/usr/share/nginx/html
      - ./data/profiler:/tmp/profiler
  workspace:
    build:
      context: ./dockerfiles/workspace
      args:
        - CUSTOM_TZ=${CUSTOM_TZ}
        - CUSTOM_LOCALE=${CUSTOM_LOCALE}
        - CUSTOM_PUID=${WORKSPACE_PUID}
        - CUSTOM_PGID=${WORKSPACE_PGID}
        - INSTALL_YADM=${WORKSPACE_INSTALL_YADM}
        - INSTALL_FINE_UTILS=${WORKSPACE_INSTALL_FINE_UTILS}
        - INSTALL_SSH=${WORKSPACE_INSTALL_SSH}
        - PHP_OPT_MEMORY_LIMIT=${WORKSPACE_PHP_OPT_MEMORY_LIMIT}
# Other args that might be used for customize in every separate container
#        - CUSTOM_COMPOSER_VERSION=1
#        - INSTALL_WP_CLI=true
#        - INSTALL_PEAR_MAIL=true
#        - INSTALL_NODE=true
#        - NODE_VERSION=v18.18.0
#        - INSTALL_PYTHON=true
#        - PYTHON_VERSION=3.12
#        - INSTALL_SUPERVISOR=false # Not ready
#        - INSTALL_LIBREOFFICE=true
#        - INSTALL_NUC_CERTS=true
#        - PHP_OPT_SHORT_OPEN_TAG=On
    restart: always
    volumes:
      - ${PROJECTS_DIR}:/var/www
      - ./data/profiler:/tmp/profiler
      - ./config/supervisor:/etc/supervisor/conf.d
    extra_hosts:
      - "dockerhost:${DOCKER_HOST_IP}"
    secrets:
      - user_ssh_key
      - user_known_hosts
      - composer_auth
  db:
    build:
      context: ./dockerfiles/db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456
    volumes:
      - database:/var/lib/mysql
      - ./hostfiles:/hostfiles
      - ./log/mariadb:/var/log/mariadb
      - ./config/mariadb:/etc/mysql/conf.d
    security_opt:
      - seccomp=unconfined
    command: [
      # increase limits for cache tables
      "--max-heap-table-size=512M",
      "--tmp-table-size=512M"
    ]
  pma:
    image: phpmyadmin/phpmyadmin
    restart: always
    environment:
      PMA_HOST: db
      PMA_USER: root
      PMA_PASSWORD: 123456
  inbucket:
    image: inbucket/inbucket
    restart: always
    expose:
      - 2500
  redis:
    image: redis
    restart: unless-stopped
    command: [ "redis-server", "/usr/local/etc/redis/redis.conf" ]
    volumes:
      - ./config/redis/redis.conf:/usr/local/etc/redis/redis.conf
      - ./config/redis/redis-local.conf:/usr/local/etc/redis/redis-local.conf
  elastic:
    build:
      context: ./dockerfiles/elastic
    restart: on-failure
    environment:
      - discovery.type=single-node
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    expose:
      - "9200"
      - "9300"
  minio:
    image: minio/minio:RELEASE.2020-06-12T00-06-19Z
    restart: always
    command: server /minio
  pm2:
    build:
      context: ./dockerfiles/pm2
    restart: unless-stopped
    expose:
      - 3000
  mcp-mariadb:
    build:
      context: ./dockerfiles/mariadb-mcp
      args:
        MARIADB_MCP_GIT_REF: ${MARIADB_MCP_GIT_REF:-main}
    restart: unless-stopped
    env_file:
      - .env.mcp-mariadb
    environment:
      LOG_FILE: /tmp/mcp_server.log
    ports:
      - "127.0.0.1:${MCP_MARIADB_PORT:-8765}:9001"
