Skip to main content

LibreOffice

Note

The default document online preview service provided by HAP is based on OnlyOffice (mingdaoyun-doc). Due to font copyright issues, some fonts may not render correctly or appear as garbled text. However, as there is no ideal free alternative product available, a mirror based on LibreOffice (mingdaoyun-ldoc) is provided for optimizing Word and PDF file previews, while Excel file preview still relies on OnlyOffice. Word and PDF file previews are based on LibreOffice.

Configuration in HAP Standalone Environment

  1. Download the mirror (Offline package)

    docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-ldoc:1.0.0
  2. Edit the docker-compose.yaml file. Add environment variables and service configurations as shown below.

    The default path of the docker-compose.yaml file is /data/mingdao/script/docker-compose.yaml.

    Alt text

    services:
    app:
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-community:5.8.1
    environment:
    ENV_DOCPREVIRE_EXT_ENDPOINTS: "ldoc:8000" # Add environment variable

    # Add service configuration
    ldoc:
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-ldoc:1.0.0
    environment:
    ENV_FILE_INNER_URI: "app:8880"
    ENV_DOCPREVIRE_SUBPATH: "/ldocpreview"
  3. Restart the HAP microservice.

Standalone deployment of ldoc services based on Docker

  1. Download the mirror (Offline package)

    docker pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-ldoc:1.0.0
  2. Initialize Docker Swarm (skip if already initialized)

    docker swarm init
  3. Create a ldoc.yaml file in any directory with the following content:

    version: '3'

    services:
    ldoc:
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-ldoc:1.0.0
    ports:
    - 8881:8000
    environment:
    ENV_FILE_INNER_URI: "Internal address of microservice application, e.g., 172.27.0.13:8880"
    ENV_DOCPREVIRE_SUBPATH: "/ldocpreview"
  4. Start the ldoc document preview service. Execute the following command in the directory where ldoc.yaml is located:

    docker stack deploy -c ldoc.yaml ldoc

    To remove the service, you can run docker stack rm ldoc.

  5. Add environment variable to the corresponding docker-compose.yaml file of the microservice (default path is /data/mingdao/script/docker-compose.yaml).

    ENV_DOCPREVIRE_EXT_ENDPOINTS: "Internal address of ldoc service, e.g., 172.27.0.13:8881"
  6. Restart the HAP microservice.

Deployment of ldoc services based on Kubernetes

  1. The cluster environment for HAP microservices is based on Kubernetes by default. To integrate ldoc service, you can deploy it using the following configuration file:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: ldoc
    namespace: default
    spec:
    replicas: 1
    selector:
    matchLabels:
    app: ldoc
    template:
    metadata:
    labels:
    app: ldoc
    spec:
    containers:
    - name: ldoc
    image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-ldoc:1.0.0
    env:
    - name: ENV_FILE_INNER_URI
    value: "www:8880"
    - name: ENV_DOCPREVIRE_SUBPATH
    value: "/ldocpreview"
    resources:
    limits:
    cpu: "4"
    memory: 4096Mi
    requests:
    cpu: "0.01"
    memory: 64Mi
    readinessProbe:
    tcpSocket:
    port: 8000
    initialDelaySeconds: 10
    periodSeconds: 10
    livenessProbe:
    tcpSocket:
    port: 8000
    initialDelaySeconds: 180
    periodSeconds: 10

    ---

    apiVersion: v1
    kind: Service
    metadata:
    name: ldoc
    namespace: default
    spec:
    selector:
    app: ldoc
    ports:
    - name: internal
    port: 8001
    targetPort: 8000
    • In the above configuration, the value of the ENV_FILE_INNER_URI variable is www:8880, which accesses the www service through internal container communication. If the deployment environment of ldoc service is not in the same namespace or environment as the HAP microservice, this variable value needs to be changed to the internal network address of the HAP system.

    • Other services to access ldoc, defined here in service it is also through the container internal communication. Similarly, if they are not in the same namespace or environment, change it to the nodePort method and configure the microservice to connect to the external address of ldoc.

  2. Add variables in config.yaml.

    ENV_DOCPREVIRE_EXT_ENDPOINTS: "ldoc:8001"
  3. Restart the HAP microservice.