Docs/CloudNative/ErrorProcess/openjdk镜像应用于图片验证码项目异常处理.md

26 lines
No EOL
871 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

openjdk默认缺少字体导致有图片验证码的乘务无法正常运行需要安装dejavu字体。
报错如下:
```txt
Exception in thread "main" java.io.IOException: Problem reading font data.
```
```bash
# 对基础镜像为alpine的openjdk镜像
cat > Dockerfile << EOF
FROM openjdk:17-jdk-alpine
RUN apk add --update --no-cache ttf-dejavu fontconfig tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk del tzdata \
&& rm -rf /var/cache/apk/* \
&& chmod +x /start.sh
EOF
# 对基础镜像为debian的openjdk镜像
cat > Dockerfile << EOF
FROM openjdk:17-jdk-slim-bullseye
RUN apt-get update && \
apt-get install -y --no-install-recommends fonts-dejavu fontconfig && \
rm -rf /var/lib/apt/lists/ && \
apt-get autoremove -y && \
apt-get autoclean -y
EOF
```