Dockerfile_arm64 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. FROM arm64v8/ubuntu:20.04
  2. MAINTAINER chenjh "842761733@qq.com"
  3. # 内置一些常用的中文字体,避免普遍性乱码
  4. COPY fonts/* /usr/share/fonts/chinese/
  5. RUN apt-get clean && apt-get update &&\
  6. sed -i 's/http:\/\/archive.ubuntu.com/https:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list &&\
  7. sed -i 's/# deb/deb/g' /etc/apt/sources.list &&\
  8. apt-get install -y --reinstall ca-certificates &&\
  9. apt-get clean && apt-get update &&\
  10. apt-get install -y locales language-pack-zh-hans &&\
  11. localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 && locale-gen zh_CN.UTF-8 &&\
  12. export DEBIAN_FRONTEND=noninteractive &&\
  13. apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
  14. apt-get install -y fontconfig ttf-mscorefonts-installer ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy &&\
  15. apt-get install -y wget
  16. # 安装 arm64-jre8
  17. RUN apt-get install -y openjdk-8-jre
  18. # 编译 libreoffice
  19. RUN apt-get install -y git build-essential zip ccache junit4 libkrb5-dev nasm graphviz python3 python3-dev qtbase5-dev libkf5coreaddons-dev libkf5i18n-dev libkf5config-dev libkf5windowsystem-dev libkf5kio-dev autoconf libcups2-dev libfontconfig1-dev gperf default-jdk doxygen libxslt1-dev xsltproc libxml2-utils libxrandr-dev libx11-dev bison flex libgtk-3-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev ant ant-optional libnss3-dev libavahi-client-dev libxt-dev &&\
  20. # 安装 ccache(重复编译时加快速度)
  21. apt-get install ccache &&\
  22. ccache -M 10G &&\
  23. # clone主代码
  24. mkdir /opt/libreoffice
  25. WORKDIR /opt/libreoffice
  26. RUN git clone --depth=1 --branch libreoffice-7-5 git://go.suokunlong.cn/lo/core ./libreoffice-7-5
  27. # 配置&抓取子模块
  28. WORKDIR /opt/libreoffice/libreoffice-7-5
  29. RUN git submodule init &&\
  30. git config --unset-all submodule.dictionaries.active &&\
  31. git config --unset-all submodule.dictionaries.url &&\
  32. git config --unset-all submodule.helpcontent2.active &&\
  33. git config --unset-all submodule.helpcontent2.url &&\
  34. git submodule update --progress --depth=1 &&\
  35. # 下载第三方依赖
  36. mkdir -p /opt/libreoffice/ext &&\
  37. wget --recursive --no-parent --no-check-certificate -P /opt/libreoffice/ext https://go.suokunlong.cn:88/dl/libreoffice/external_tarballs/
  38. RUN mv /opt/libreoffice/ext/go.suokunlong.cn:88/dl/libreoffice/external_tarballs/* /opt/libreoffice/ext
  39. # 配置编译选项
  40. RUN cat << EOF > autogen.input \
  41. && echo "--without-help" >> autogen.input \
  42. && echo "--without-helppack-integration" >> autogen.input \
  43. && echo "--with-lang=zh-CN zh-TW" >> autogen.input \
  44. && echo "--disable-online-update" >> autogen.input \
  45. && echo "--disable-breakpad" >> autogen.input \
  46. && echo "--disable-odk" >> autogen.input \
  47. && echo "--without-doxygen" >> autogen.input \
  48. && echo "--with-external-tar=/opt/libreoffice/ext" >> autogen.input \
  49. && echo "--without-java" >> autogen.input \
  50. && echo "--enable-firebird-sdbc" >> autogen.input \
  51. && echo "--without-system-firebird" >> autogen.input \
  52. && echo "--enable-python=internal" >> autogen.input
  53. # 预编译
  54. RUN ./autogen.sh
  55. # 因为libreoffice的安全策略,不允许root用户执行编译操作(可以改Makefile文件解决),所以新建用户
  56. RUN useradd libreoffice
  57. # 切换用户
  58. RUN su libreoffice
  59. # 在普通用户下编译
  60. RUN make || true
  61. # !!!编译40分钟左右会报错,此时需要执行以下操作重新编译
  62. RUN cp ./workdir/UnpackedTarball/python3/build/lib.linux-aarch64-3.8/_sysconfigdata__linux_aarch64-linux-gnu.py ./workdir/UnpackedTarball/python3/build/lib.linux-aarch64-3.8/_sysconfigdata__linux_aarch64-unknown-linux-gnu.py
  63. # 重新编译
  64. RUN make &&\
  65. make install
  66. RUN ln -s /usr/local/lib/libreoffice/program/soffice /usr/bin/libreoffice
  67. # 清理临时文件
  68. RUN rm -rf /tmp/* && rm -rf /var/lib/apt/lists/* &&\
  69. cd /usr/share/fonts/chinese &&\
  70. mkfontscale &&\
  71. mkfontdir &&\
  72. fc-cache -fv
  73. ENV LANG zh_CN.UTF-8
  74. ENV LC_ALL zh_CN.UTF-8
  75. CMD ["/bin/bash"]