From 440b8030e045aa0369ad5b5a582e4e90a57603f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=B2=BE=E5=8D=8E?= <842761733@qq.com> Date: Mon, 17 Jun 2019 18:13:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EDocker=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +-- Dockerfile | 30 +++++++++++++++++++ fonts/.gitkeep | 0 .../src/main/bin/docker-startup.sh | 29 ++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100644 fonts/.gitkeep create mode 100644 jodconverter-web/src/main/bin/docker-startup.sh diff --git a/.gitignore b/.gitignore index 0b3471f6..ad7359a3 100644 --- a/.gitignore +++ b/.gitignore @@ -38,5 +38,5 @@ nbdist/ /.temfile .temfile convertedFile/ -jodconverter-web/src/main/file -jodconverter-web/src/main/cache \ No newline at end of file +jodconverter-web/src/main/cache/ +jodconverter-web/src/main/file/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..6f525385 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM centos:centos7.6.1810 +MAINTAINER chenjh "842761733@qq.com" +ADD jodconverter-web/target/kkFileView-*.tar.gz /opt/ +COPY fonts/* /usr/share/fonts/ +RUN yum install -y kde-l10n-Chinese &&\ + yum install -y glibc-common &&\ + yum install -y fontconfig &&\ + yum install -y mkfontscale &&\ + localedef -c -f UTF-8 -i zh_CN zh_CN.utf8 &&\ + export LANG=zh_CN.UTF-8 &&\ + echo "export LANG=zh_CN.UTF-8" >> /etc/locale.conf &&\ + LANG="zh_CN.UTF-8" &&\ + yum install -y java-1.8.0-openjdk.x86_64 &&\ + yum install -y wget &&\ + yum install -y libXext.x86_64 &&\ + yum groupinstall -y "X Window System" &&\ + cd /tmp &&\ + wget https://iweb.dl.sourceforge.net/project/openofficeorg.mirror/4.1.6/binaries/zh-CN/Apache_OpenOffice_4.1.6_Linux_x86-64_install-rpm_zh-CN.tar.gz -cO openoffice_rpm.tar.gz &&\ + tar zxf /tmp/openoffice_rpm.tar.gz &&\ + cd /tmp/zh-CN/RPMS &&\ + rpm -Uvih *.rpm &&\ + rpm -Uvih desktop-integration/openoffice4.1.6-redhat-menus-4.1.6-9790.noarch.rpm &&\ + rm -f /tmp/openoffice_rpm.tar.gz &&\ + rm -rf /tmp/zh-CN &&\ + cd /usr/share/fonts &&\ + mkfontscale &&\ + mkfontdir &&\ + fc-cache -fv +ENV LC_ALL zh_CN.UTF-8 +CMD sh /opt/kkFileView-2.1.0-SNAPSHOT/bin/docker-startup.sh \ No newline at end of file diff --git a/fonts/.gitkeep b/fonts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/jodconverter-web/src/main/bin/docker-startup.sh b/jodconverter-web/src/main/bin/docker-startup.sh new file mode 100644 index 00000000..03fb6955 --- /dev/null +++ b/jodconverter-web/src/main/bin/docker-startup.sh @@ -0,0 +1,29 @@ +#!/bin/bash +DIR_HOME=("/opt/openoffice.org3" "/opt/libreoffice" "/opt/openoffice4" "/usr/lib/openoffice" "/usr/lib/libreoffice") +FLAG= +OFFICE_HOME= +KKFILEVIEW_BIN_FOLDER=$(cd "$(dirname "$0")";pwd) +export KKFILEVIEW_BIN_FOLDER=$KKFILEVIEW_BIN_FOLDER +cd $KKFILEVIEW_BIN_FOLDER +echo "Using KKFILEVIEW_BIN_FOLDER $KKFILEVIEW_BIN_FOLDER" +grep 'office\.home' ../conf/application.properties | grep '!^#' +if [ $? -eq 0 ]; then + echo "Using customized office.home" +else + for i in ${DIR_HOME[@]} + do + if [ -f $i"/program/soffice.bin" ]; then + FLAG=true + OFFICE_HOME=${i} + break + fi + done + if [ ! -n "${FLAG}" ]; then + echo "Installing OpenOffice" + sh ../script/install.sh + else + echo "Detected office component has been installed in $OFFICE_HOME" + fi +fi +echo "Starting kkFileView..." +java -Dsun.java2d.cmm=sun.java2d.cmm.kcms.KcmsServiceProvider -Dspring.config.location=../conf/application.properties -jar kkFileView-2.1.0-SNAPSHOT.jar \ No newline at end of file