当前位置:首页 > 系统运维
使用 Dockerfile 构建 kkFileView 镜像
来源:靑龍一笑的博客  作者:靑龍一笑  发布时间:2021-11-10 11:27:00  点击量:1094  评论:0
[root@RicenOS softwares]# mkdir -pv kkFileView
[root@RicenOS softwares]# cd kkFileView/

    准备三个软件包:kkFileView-4.0.0.tar.gz、LibreOffice_7.2.2_Linux_x86-64_deb.tar.gz、jdk-8u301-linux-x64.tar.gz。
    编写 Dockerfile 文件:

[root@RicenOS kkFileView]# vi Dockerfile

    内容如下:

# 基础镜像
FROM ubuntu:20.04
# 准备 kkFileView、LibreOffice 和 JDK
ADD kkFileView-4.0.0.tar.gz jdk-8u301-linux-x64.tar.gz LibreOffice_7.2.2_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 locales && apt-get install -y 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 &&\
apt-get install -y tzdata && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\
apt-get install -y libxrender1 && apt-get install -y libxt6 && apt-get install -y libxext-dev && apt-get install -y libfreetype6-dev &&\
apt-get install -y wget && apt-get install -y ttf-mscorefonts-installer && apt-get install -y fontconfig &&\
apt-get install ttf-wqy-microhei &&\
apt-get install ttf-wqy-zenhei &&\
apt-get install xfonts-wqy &&\
mv /opt/jdk1.8.0_301 /usr/local/ &&\
apt-get install -y libxinerama1 libcairo2 libcups2 libx11-xcb1 &&\
cd /opt/LibreOffice_7.2.2.2_Linux_x86-64_deb/DEBS &&\
dpkg -i *.deb &&\
cd ~ && rm -rf /var/lib/apt/lists/*
# 设置环境变量
ENV JAVA_HOME /usr/local/jdk1.8.0_301
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.0.0/bin
ENV KK_OFFICE_HOME=/opt/libreoffice7.2
# 容器的入口,启动后需要执行的程序
ENTRYPOINT ["java","-Dfile.encoding=UTF-8","-Dspring.config.location=/opt/kkFileView-4.0.0/config/application.properties","-jar","/opt/kkFileView-4.0.0/bin/kkFileView-4.0.0.jar"]

    构建镜像:

[root@RicenOS kkFileView]# docker image build -t kkfileview .

    创建并启动 kkfileview 容器:

[root@RicenOS kkFileView]# docker run -it -p 8012:8012 kkfileview

    当然,也可以编写 docker-compose.yml 文件,内容如下:

version: "3.0"
services: 
    kkfileview: 
        container_name: kkfileview
        hostname: kkfileview
    build:
        context: .
        dockerfile: Dockerfile
        restart: always
        ports: 
            - 8012:8012

    使用 docker-compose 命令构建并运行 kkfileview:

[root@RicenOS kkFileView]# docker-compose -f docker-compose.yml up -d
版权所有 © 2005-2023 靑龍一笑的博客  Powered by C.S.Ricen
Copyright © 2005-2023 by www.ricensoftwares.com.cn  All Rights Reserved.

欢迎光临本站,这里是靑龍一笑的博客。

因资金匮乏,本站已迁到国外的免费空间,可能导致本站的访问速度较慢,由此给您带来的不便,敬请谅解。

您可以通过下方的“支持本站建设”链接,给本站提供资金支持。

Free Web Hosting