JEECG deployment: the problem of Alpine image

In this article, I want to remember the problems of using Alpine image in JEECG deployment.

Dockerfile

FROM nginx:1.18-alpine

MAINTAINER liumiao liumiaocn@outlook.com

RUN  apk update \
     && apk add openjdk8-jre-base \
     && touch /etc/init.d/start.sh \
     && chmod +x /etc/init.d/start.sh \
     && echo "#!/bin/sh  " >> /etc/init.d/start.sh \
     && echo "/usr/sbin/nginx  -c /etc/nginx/nginx.conf" >> /etc/init.d/start.sh \
     && echo " java -jar /jeecgboot.jar   " >> /etc/init.d/start.sh

ADD jeecg-boot-module-system-2.2.0.jar jeecgboot.jar
ADD dist/ /usr/share/nginx/html/
ADD default.conf /etc/nginx/conf.d/default.conf

EXPOSE 80 8080
ENTRYPOINT /bin/sh -c   /etc/init.d/start.sh

default.conf

server {
        listen       80;
        location ^~ /jeecg-boot {
        proxy_pass              http://127.0.0.1:8080/jeecg-boot/;
        proxy_set_header        Host 127.0.0.1;
        proxy_set_header        X-Real-IP \$remote_addr;
        proxy_set_header        X-Forwarded-For \$proxy_add_x_forwarded_for;
    } 
    location / {
       root   /var/www/html/;
        index  index.html index.htm;
        if (!-e \$request_filename) {
            rewrite ^(.*)\$ /index.html?s=\$1 last;
            break;
        }
    }
    access_log  /var/log/nginx/access.log ;
}

Post startup issues

Reason and tentative correspondence

Take a look at the class name of NoClassDefFound sun.awt , probably using Oracle's JDK can solve the problem. Because Oracle's JDK is based on GLIBC, Alpine has to leave it first. This is probably because there is a very rough Dockerfile in the source code of JEECG, which is based on CentOS7. So we can directly fix the problem by changing the Dockerfile to CentOS based.

remarks

It seems that you can solve the problem of Font by installing APK add TTF dejavu. You will continue to confirm later.

Tags: Nginx Oracle JDK Java

Posted on Thu, 04 Jun 2020 10:22:59 -0700 by Onle