captainVersion: 4
services:
    $$cap_appname:
        image: osixia/openldap:$$cap_openldap_version
        restart: always
        volumes:
            - $$cap_appname-db:/var/lib/ldap
            - $$cap_appname-config:/etc/ldap/slapd.d
        environment:
            LDAP_ORGANISATION: $$cap_openldap_ldap-organisation
            LDAP_DOMAIN: $$cap_root_domain
            LDAP_ADMIN_PASSWORD: $$cap_openldap_ldap-admin-password
        caproverExtra:
            notExposeAsWebApp: 'true'
    $$cap_appname-admin:
        image: osixia/phpldapadmin:$$cap_phpldapadmin_version
        restart: always
        depends_on:
            - $$cap_appname
        environment:
            PHPLDAPADMIN_TRUST_PROXY_SSL: true
            PHPLDAPADMIN_LDAP_HOSTS: srv-captain--$$cap_appname
            PHPLDAPADMIN_SERVER_ADMIN: $$cap_phpldapadmin_admin-email
            PHPLDAPADMIN_SERVER_PATH: https://$$cap_appname-admin.$$cap_root_domain
            PHPLDAPADMIN_HTTPS: false
caproverOneClickApp:
    variables:
        - id: $$cap_openldap_version
          label: Openldap Version
          defaultValue: 1.4.0
          description: Check out their docker page for the valid tags https://hub.docker.com/r/osixia/openldap/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_openldap_ldap-organisation
          label: Ldap Organisation
          description: The Organization name
          validRegex: /.{1,}/
        - id: $$cap_openldap_ldap-admin-password
          label: The admin Password
          description: The admin password of the Openldap
          validRegex: /.{1,}/
        - id: $$cap_phpldapadmin_version
          label: PHPLadapAdmin Version
          defaultValue: 0.9.0
          description: Check out their docker page for the valid tags https://hub.docker.com/r/osixia/phpldapadmin/tags
          validRegex: /^([^\s^\/])+$/
        - id: $$cap_phpldapadmin_admin-email
          label: The admin email
          description: The admin email of the Openldap administration interface
          validRegex: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/
    instructions:
        start: OpenLDAP Software is an open source implementation of the Lightweight Directory Access Protocol.
        end: OpenLDAP is deployed and the admin interface is available on http://$$cap_appname-admin.$$cap_root_domain. You can connect by adapting cn=admin,dc=my-company,dc=com. If you want to access to your ldap server from outside, do not forget to add port mapping (389 for ldap with starttls, 636 for ldaps).
    displayName: OpenLDAP + phpLDAPadmin
    description: OpenLDAP with administration interface
    documentation: https://github.com/osixia/docker-openldap
