chenzl 10 mesi fa
parent
commit
e44436a829
3 ha cambiato i file con 55 aggiunte e 1 eliminazioni
  1. 34 0
      DockerfileProd
  2. 1 1
      compose.yml
  3. 20 0
      prod-compose.yml

+ 34 - 0
DockerfileProd

@@ -0,0 +1,34 @@
+FROM ubuntu:20.04
+# 准备 kkFileView、LibreOffice 和 JDK
+COPY server/target/kkFileView-4.4.0-SNAPSHOT.tar.gz /opt/
+COPY server/tool/jdk-8u202-linux-x64.tar.gz /opt/
+COPY server/tool/LibreOffice_7.6.4_Linux_x86-64_deb.tar.gz /opt/
+# 升级系统,安装相关的依赖包和字体、安装 JDK、LibreOffice
+RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse\ndeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse\ndeb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" > /etc/apt/sources.list &&\
+    apt-get clean && apt-get update &&\
+    apt-get install -y --reinstall ca-certificates &&\
+    apt-get clean && apt-get update &&\
+    apt-get install -y locales language-pack-zh-hans &&\
+    localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 && locale-gen zh_CN.UTF-8 &&\
+    export DEBIAN_FRONTEND=noninteractive &&\
+    apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
+    apt-get install -y fontconfig ttf-mscorefonts-installer ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy && \
+    apt-get install -y libxrender1 libxinerama1 libxt6 libxext-dev libfreetype6-dev libcairo2 libcups2 libx11-xcb1 libnss3 &&\
+    cd /opt && tar -xvf jdk-8u202-linux-x64.tar.gz && mv jdk1.8.0_202 /usr/local/ &&\
+    tar -xvf kkFileView-4.4.0-SNAPSHOT.tar.gz &&\
+    tar -xvf LibreOffice_7.6.4_Linux_x86-64_deb.tar.gz &&\
+    cd LibreOffice_7.6.4.1_Linux_x86-64_deb/DEBS &&\
+    dpkg -i *.deb &&\
+    cd ~ && rm -rf /var/lib/apt/lists/*
+# 设置环境变量
+ENV JAVA_HOME /usr/local/jdk1.8.0_202
+ENV CLASSPATH $JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
+ENV PATH $PATH:$JAVA_HOME/bin
+ENV LANG zh_CN.UTF-8
+ENV LC_ALL zh_CN.UTF-8
+ENV KKFILEVIEW_BIN_FOLDER /opt/kkFileView-4.4.0-SNAPSHOT/bin
+ENV KK_OFFICE_HOME=/opt/libreoffice7.6
+ENV KK_TRUST_HOST=cdn.uxianxin.com,fresh-life.oss-cn-shanghai.aliyuncs.com,file.uxianxin.com
+ENV KK_BASE_URL=https://file.uxianxin.com
+# 容器的入口,启动后需要执行的程序
+ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.4.0-SNAPSHOT/config/application.properties","-jar","/opt/kkFileView-4.4.0-SNAPSHOT/bin/kkFileView-4.4.0-SNAPSHOT.jar"]

+ 1 - 1
compose.yml

@@ -10,7 +10,7 @@ services:
     build:
       context: ./         # 指定设定上下文根目录,然后以该目录为准寻找Dockerfile
       dockerfile: Dockerfile  #DockerFile 真正所在位置
-    image: file-preview:0.0.1
+    image: file-preview:1.0.0
     volumes:
       # 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
       - /usr/local/youxianxin/service/log/file-preview:/logback

+ 20 - 0
prod-compose.yml

@@ -0,0 +1,20 @@
+version: "3"
+services:
+
+  file-preview:
+    # 指定容器名称
+    container_name: file-preview
+    # 重启机制
+    restart: always
+    network_mode: "host"
+    build:
+      context: ./         # 指定设定上下文根目录,然后以该目录为准寻找Dockerfile
+      dockerfile: DockerfileProd  #DockerFile 真正所在位置
+    image: file-preview:1.0.0
+    volumes:
+      # 挂载日志 -v A:B ,A指宿主机位置,B指容器位置
+      - /usr/local/youxianxin/service/log/file-preview:/logback
+      # 指定容器时间为宿主机时间
+      - /etc/localtime:/etc/localtime
+    #启动容器后执行的命令
+