# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Casdoor
spec:
    description: A UI-first Identity Access Management (IAM) / Single-Sign-On (SSO) platform
    icon: https://casdoor.org/img/casdoor.png
    readme: |
        # Casdoor

        Casdoor is a UI-first Identity Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML, CAS, LDAP, SCIM, WebAuthn, TOTP, MFA, RADIUS, Google Workspace, Active Directory and Kerberos.

        For details, see [their documentation](https://casdoor.org/).

        ## Deployment

        This is a one-click deployment. After deploying, bind your domain to the Casdoor service, and you can access it through that domain. The default username and password are `admin` and `123`.
    services:
        - name: mysql
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/mysql.svg
          template: PREBUILT
          spec:
            id: mysql
            source:
                image: mysql:8.0.33
            ports:
                - id: database
                  port: 3306
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/mysql
            instructions:
                - title: Command to connect to your MySQL
                  content: mysqlsh --sql --host=${PORT_FORWARDED_HOSTNAME} --port=${DATABASE_PORT_FORWARDED_PORT} --user=${MYSQL_USERNAME} --password=${MYSQL_PASSWORD} --schema=${MYSQL_DATABASE}
                - title: MySQL username
                  content: ${MYSQL_USERNAME}
                - title: MySQL password
                  content: ${MYSQL_PASSWORD}
                - title: MySQL database
                  content: ${MYSQL_DATABASE}
                - title: MySQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: MySQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                MYSQL_DATABASE:
                    default: casdoor
                    expose: true
                MYSQL_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                MYSQL_PASSWORD:
                    default: ${MYSQL_ROOT_PASSWORD}
                    expose: true
                MYSQL_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                MYSQL_ROOT_PASSWORD:
                    default: ${PASSWORD}
                MYSQL_USERNAME:
                    default: root
                    expose: true
            configs:
                - path: /etc/my.cnf
                  template: |
                    [mysqld]
                    default-authentication-plugin=mysql_native_password
                    skip-host-cache
                    skip-name-resolve
                    datadir=/var/lib/mysql
                    socket=/var/run/mysqld/mysqld.sock
                    secure-file-priv=/var/lib/mysql-files
                    user=mysql
                    max_allowed_packet=10M

                    pid-file=/var/run/mysqld/mysqld.pid
                    [client]
                    socket=/var/run/mysqld/mysqld.sock

                    !includedir /etc/mysql/conf.d/
                  permission: null
                  envsubst: null
        - name: casdoor
          icon: https://casdoor.org/img/casdoor.png
          template: PREBUILT
          spec:
            id: casdoor
            source:
                image: casbin/casdoor:latest
            ports:
                - id: web
                  port: 8000
                  type: HTTP
                - id: ldap
                  port: 389
                  type: TCP
                - id: radius
                  port: 1812
                  type: TCP
            env:
                dataSourceName:
                    default: ${MYSQL_USERNAME}:${MYSQL_PASSWORD}@tcp(${MYSQL_HOST}:${MYSQL_PORT})/
                driverName:
                    default: mysql
            configs:
                - path: /conf/app.conf
                  template: |
                    appname = casdoor
                    httpport = 8000
                    runmode = dev
                    copyrequestbody = true
                    dbName = casdoor
                    tableNamePrefix =
                    showSql = false
                    redisEndpoint =
                    defaultStorageProvider =
                    isCloudIntranet = false
                    authState = "casdoor"
                    socks5Proxy = """
                    verificationCodeTimeout = 10
                    initScore = 0
                    logPostOnly = true
                    isUsernameLowered = false
                    origin =
                    originFrontend =
                    staticBaseUrl = "https://cdn.casbin.org"
                    isDemoMode = false
                    batchSize = 100
                    enableErrorMask = false
                    enableGzip = true
                    ldapServerPort = 389
                    radiusServerPort = 1812
                    radiusSecret = "secret"
                    quota = {"organization": -1, "user": -1, "application": -1, "provider": -1}
                    logConfig = {"filename": "logs/casdoor.log", "maxdays":99999, "perm":"0770"}
                    initDataFile = "./init_data.json"
                    frontendBaseDir = "../casdoor"
                  permission: null
                  envsubst: null
