Dockerfile内容如下:
FROM eclipse-temurin:8-jre-alpine LABEL maintainer="devops@example.com" RUN apk update && apk --no-cache add tzdata ttf-dejavu fontconfig \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 RUN mkdir -p $JAVA_HOME/lib/fonts/fallback/ \ && cd $JAVA_HOME/lib/fonts/fallback/ \ && wget http://b.pig4cloud.com/SIMSUN.TTC RUN mkdir -p /data/server RUN addgroup -g 8080 -S app \ && adduser app -h /data/server -D -G app -u 8080 -s /bin/sh USER app WORKDIR /data/server
解决docker alpine缺少字体的问题,Dockerfile内容如下:
FROM frolvlad/alpine-java:jre8-slim LABEL maintainer="devops@example.com" RUN apk update && apk --no-cache add tzdata ttf-dejavu fontconfig \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone ENV LANG=en_US.UTF-8 \ LANGUAGE=en_US.UTF-8 RUN mkdir -p $JAVA_HOME/lib/fonts/fallback/ \ && cd $JAVA_HOME/lib/fonts/fallback/ \ && wget http://b.pig4cloud.com/SIMSUN.TTC RUN mkdir -p /data/server RUN addgroup -g 8080 -S app \ && adduser app -h /data/server -D -G app -u 8080 -s /bin/sh USER app WORKDIR /data/server
备注:增加时区、字体、非root用户