阅读 2398

使用Docker构建支持中文字体的Java镜像

在构建镜像的过程中安装字体管理器和中文字体

  1. 构建jre镜像,参考这篇文章:

    Docker构建自定义的Java镜像:https://blog.csdn.net/zimou5581/article/details/9402274

  2. 如何安装中文字体,参考这篇文章

    如何给dcoker容器里的alpine系统安装中文字体:https://blog.csdn.net/zimou5581/article/details/101368129

  3. 文件目录如图

    在这里插入图片描述

  4. 构建镜像的Dockerfile

    # using alpine-glibc instead of alpine  is mainly because JDK relies on glibc
    FROM docker.io/jeanblanchard/alpine-glibc
    # author
    MAINTAINER ygsama@qq.com
    # A streamlined jre
    ADD jre8.tar.gz /usr/java/jdk/
    ADD msyhbd.ttc  /opt/
    ADD msyhl.ttc   /opt/
    ADD msyh.ttc    /opt/
    ADD simhei.ttf  /opt/
    ADD simkai.ttf  /opt/
    ADD simsun.ttc  /opt/
    # set env
    ENV JAVA_HOME /usr/java/jdk
    ENV PATH ${PATH}:${JAVA_HOME}/bin
    ENV CLASSPATH ${CLASSPATH}:${JAVA_HOME}/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
    # run container with base path:/opt
    WORKDIR /opt
    # install font
    RUN apk add font-adobe-100dpi \
        && chmod 777 *.ttc \
        && chmod 777 *.ttf \
        && mkdir /usr/share/fonts/win \
        && mv msyhbd.ttc /usr/share/fonts/win/  \
        && mv msyhl.ttc  /usr/share/fonts/win/  \
        && mv msyh.ttc   /usr/share/fonts/win/  \
        && mv simhei.ttf /usr/share/fonts/win/  \
        && mv simkai.ttf /usr/share/fonts/win/  \
        && mv simsun.ttc /usr/share/fonts/win/  \
        && fc-cache -f \
        && fc-list
    复制代码
文章分类
后端
文章标签