JeecgBoot 官网链接

一. docker 基础
本章非普及类文章,仅做简单介绍。未学习的同学建议异步学习,-》》》 docker菜鸟基础教程
二、环境介绍
使用到的内容是基于jeecgboot来进行的( java、nginx、 mysql、 redis),都是较为基础的模块,未了解同学,自行搜索!
具体运行环境, macOs,Docker Desktop Community Version 2.0.0.2 (30215) , openJdk 1.8 ,nginx
三、 制作流程
mysql、redis 对应docker安装参考 参考链接
1.选择对应的基础镜像 ubuntu:lastest
在对应目录新建 Dockerfile
在这里插入图片描述
2.更新最新的镜像源 确保能够安装jdk 和nginx
# 基础镜像 FROM ubuntu:latest
3.安装对应的软件
采用阿里的镜像源
RUN echo " deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse" > /etc/apt/sources.list \ && apt-get update \ && apt-get -y install nginx \ && apt-get -y install openjdk-8-jre \
4.配置对应的nginx参数
基础的nginx 配置 参考官方配置 传送门
5.docker build Dockerfie
docker build -t docker .
6.查看 并运行
docker images
在这里插入图片描述
运行:
docker run --name jeecgboot -p 81:80 -p 8080:8080 jeecgboot
在这里插入图片描述
在这里插入图片描述

	进入容器:
	clear && docker exec -it jeecgboot sh

四、 章程效果
本次文章最终以 本地打包jeecg应用,本地运行为基准,属于较为基础的教程!
以下是全部内容

# Version 0.1
# 基础镜像
FROM ubuntu:latest
# 维护者信息
MAINTAINER ksf@zgykkj.com
VOLUME /tmp
#自动安装依赖
RUN  echo " deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties \n\
             deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted \n\
            deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted \n\
            deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial universe \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse   \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n\
            deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties \n\
            deb http://archive.canonical.com/ubuntu xenial partner \n\
            deb-src http://archive.canonical.com/ubuntu xenial partner \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted \n\
            deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe \n\
            deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse" > /etc/apt/sources.list \
    && apt-get update \
    &&  apt-get -y  install nginx \
    &&  apt-get -y  install openjdk-8-jre \
    &&  apt-get -y  install redis-server \

#这里可以设置 域名
# 可以送本地加载 使用ADD 也可以直接写
   && echo "server {  \
                        listen       80; \n\
                        location ^~ /jeecg-boot { \n\
                       proxy_pass              http://127.0.0.1:8080/jeecg-boot/; \n\
                       proxy_set_header        Host 127.0.0.1; \n\
                       proxy_set_header        X-Real-IP \$remote_addr; \n\
                       proxy_set_header        X-Forwarded-For \$proxy_add_x_forwarded_for; \n\
                   } \n\
                   #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 \n\
                   location / { \n\
                      root   /var/www/html/; \n\
                       index  index.html index.htm; \n\
                       if (!-e \$request_filename) { \n\
                           rewrite ^(.*)\$ /index.html?s=\$1 last; \n\
                           break; \n\
                       } \n\
                   } \n\
                   access_log  /var/log/nginx/access.log ; \n\
               } " > /etc/nginx/sites-available/default \
 # 设置启动脚本
     && touch /start.sh \
     && chmod +x /start.sh \
  # 可以送本地加载 使用ADD 也可以直接导入
     && echo " service nginx start \n\
                service redis-server start \n\
            java -jar /jeecgboot.jar"> /start.sh
# 前端迁移到系统文件中 默认是80端口
ADD  ant-design-vue-jeecg/dist/ /var/www/html/
ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.0.2.jar jeecgboot.jar
EXPOSE  80  8080
ENTRYPOINT /start.sh

#启动脚本
# docker run --name jeecgboot2 -p 81:80 -p 8080:8080  -d jeecgboot


运行后点击开发

基于centos 7 镜像的 运行环境 增加redis 脚本

处理centos 7镜像的不能service systemctl的解决方式处理。 详情看文档喽

# Version 0.1
# 基础镜像
FROM local/systemd_centos7
# 维护者信息
MAINTAINER ksf@zgykkj.com
VOLUME /tmp
#自动安装依赖
RUN  cd /etc/yum.repos.d/ \
    && yum -y install wget \
    && wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \
    && yum clean all \
    && yum makecache \
    && yum update -y \
    &&  yum -y  install nginx ; \
    &&  yum -y  install  java-1.8.0-openjdk java-1.8.0-openjdk-devel  \
    &&  yum -y  install redis ;   \
#这里可以设置 域名
# 可以送本地加载 使用ADD 也可以直接写
   && echo "server {  \
                       listen       81; \
                       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; \
                  } \
                  #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 \
                  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 ; \
              } " > /etc/nginx/conf.d/default.conf  \

 # 设置启动脚本
     && touch /etc/init.d/start.sh \
     && touch jeecgboot.log \
     && chmod +x /etc/init.d/start.sh \
     && echo "#!/bin/bash  " >> /etc/init.d/start.sh \
     && echo "/usr/bin/redis-server  & " >> /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 \
     &&  mkdir  -p  /var/www \
     &&  mkdir -p /var/www/html
# 前端迁移到系统文件中 默认是80端口
ADD  ant-design-vue-jeecg/dist/ /var/www/html/
ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.0.2.jar jeecgboot.jar
EXPOSE  80  8080 81
ENTRYPOINT /bin/sh -c   /etc/init.d/start.sh

#启动脚本
#docker rmi $(docker images | grep "^<none>" | awk "{print $3}") 删除<none>
#docker build -t jeecgboot:centos .
#docker run --privileged=true  -itd --name test -v /sys/fs/cgroup:/sys/fs/cgroup:ro  -p 81:81 -p 8080:8080 -p 82:80  jeecgboot:centos

运行后点击开发

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐