Python3 - Docker部署Libre Office Online在线文件转换

1. 查找 Libre Office Online 镜像文件

[harry@iZ8vbbio60rq3uZ ~]$ docker search libreoffice
NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
libreoffice/online                           LibreOffice Online (x86-64 only)                127                  
xcgd/libreoffice                             A headless libreoffice server                   24                   [OK]
linuxserver/libreoffice                                                                      20           

2. 拉取最新tag镜像文件到本地

[harry@iZ8vo60rq3uZ ~]$ docker pull libreoffice/online:latest
[harry@iZ8vb0orq3uZ ~]$  docker images  
REPOSITORY            TAG       IMAGE ID       CREATED         SIZE
portainer/portainer   latest    580c0e4e98b0   17 months ago   79.1MB
libreoffice/online    latest    79c8fb91fad0   23 months ago   2.92GB

3. 创建并启动LibreOffice Online 服务

[harry@iZ8vb0orq3uZ ~]$  docker run -t -d -p 9980:9980  -e "username=admin" -e "password=123456" --restart always --cap-add MKNOD libreoffice/online

-e "username=admin"   # Libre office online web 管理控制台用户名/密码
-e "password=123456" 
--cap-add MKNOD   #添加 Linux mknod (创建特殊文件)功能

4. 配置Office 应用配置,修改HTTPS为HTTP

由于Libre Office Online 默认配置为HTTPS ,因此,无法正常通过HTTP 正常访问,因此需要修改应用的配置文件:

4.1 获取Docker 容器内的配置文件到当前目录下:

  1. 禁用SSL 加密传输:(其默认是True,开启)

    [harry@iZ8vb0orq3uZ ~]$ docker cp 1ef8c0ecf467:/etc/loolwsd/loolwsd.xml /home/harry/loolwsd.xml
    
    [harry@iZ8vb0orq3uZ ~]$ vim loolwsd.xml
    <ssl desc="SSL settings">
            <enable type="bool" desc="Controls whether SSL encryption between browser and loolwsd is enabled (do not disable for production deployment). If default is false, must first be compiled with SSL support to enable." default="true">**false**</enable>
    
  2. 将配置文件重新复制到容器中,并重新启动Office 容器

    [harry@iZ8vb0orq3uZ ~]$ docker cp /home/harry/loolwsd.xml 1ef8c0ecf467:/etc/loolwsd/loolwsd.xml
    [harry@iZ8vb0orq3uZ ~]$ docker restart  1ef8c0ecf467
    

5. 查看LibreOffice Online 服务运行状态

[harry@iZ8vbbip0rq3uZ ~]$ docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED             STATUS             PORTS                                                                      NAMES
456a7f4f4a25   portainer/portainer   "/portainer"             41 minutes ago      Up 41 minutes      0.0.0.0:9000->9000/tcp, :::9000->9000/tcp                                  determined_ramanujan
1ef8c0ecf467   libreoffice/online    "/bin/sh -c 'bash /r…"   About an hour ago   Up About an hour   0.0.0.0:9980->9980/tcp, :::9980->9980/tcp                                  admiring_shamir

直接访问:http://IP:9980/loleaflet/dist/admin/admin.html

在这里插入图片描述

如上所示的Web管理控制平台

6. 验证Libre Office Online 安装:

  1. 访问: http://IP:9980 ,返回OK,即为安装成功;
  2. 直接访问:http://IP:9980/loleaflet/dist/admin/admin.html, 出现xml内容,证明软件安装成功了

7. 验证Libre Office Online 文件转换:

[harry@iZ8vbbip40rq3uZ ~]$ curl -F "[email protected]" http://IP:9980/lool/convert-to/pdf > out.pdf
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   242    0     0  100   242      0    120  0:00:02  0:00:02 --:--:--   120

如上所示:接收到out.pdf 文件,文件转换服务,到此就完成部署。

猜你喜欢

转载自blog.csdn.net/qq_31810357/article/details/126300176