下载支持中文所需文件
# 密钥下载
https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
# 依赖库下载
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-2.25-r0.apk
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-bin-2.25-r0.apk
https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.25-r0/glibc-i18n-2.25-r0.apk
注意glibc版本, 目前验证2.25没有问题, 使用2.35执行/usr/glibc-compat/bin/localedef会报错
JDK环境Dockerfile文件
FROM alpine:latest
# Configruation Zh_CN
COPY sgerrand.rsa.pub /etc/apk/keys/sgerrand.rsa.pub
COPY glibc-2.25-r0.apk glibc-bin-2.25-r0.apk glibc-i18n-2.25-r0.apk locale.md ./
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && \
apk --no-cache add ca-certificates tzdata curl && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apk del tzdata && \
apk add glibc-bin-2.25-r0.apk glibc-i18n-2.25-r0.apk glibc-2.25-r0.apk && \
cat locale.md | xargs -i /usr/glibc-compat/bin/localedef -i {} -f UTF-8 {}.UTF-8 && \
rm -f glibc-bin-2.25-r0.apk glibc-i18n-2.25-r0.apk glibc-2.25-r0.apk locale.md
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8
# Install JDK1.8
ADD jdk1.8.0_291.tar.gz /usr/java1.8/
ENV JAVA_HOME /usr/java1.8/jdk1.8.0_291
ENV JRE_HOME ${JAVA_HOME}/jre
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV PATH ${JAVA_HOME}/bin:$PATH
构建镜像
docker build -t oracle-jdk8u291-alpine_zh:v1 .
Java项目运行环境Dockerfile
FROM oracle-jdk8u291-alpine_zh:v1
ADD *.jar /app/
# env for application
ENV PORT=""
ENV JAVA_OPTS=""
ENV APP_ARGS=""
ENV AGENT_ARGS=""
WORKDIR /app
EXPOSE $PORT
ENTRYPOINT ["/bin/bash","-c","java ${AGENT_ARGS} ${JAVA_OPTS} ${APP_ARGS} -jar /app/*.jar"]