# Version 0.1
# 基础镜像
FROM centos:7
# 维护者信息
MAINTAINER XinTong
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 ^~ /prod-api { \
                      proxy_pass              http://127.0.0.1:8090/api; \
                      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 yjzh.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 /app.jar   " >> /etc/init.d/start.sh \
     &&  mkdir  -p  /var/www \
     &&  mkdir -p /var/www/html
# 前端迁移到系统文件中 默认是80端口 同级目录下的html地址
ADD  ruoyi-ui/dist /var/www/html/
# 拷贝相关的jar包
ADD ruoyi-admin/target/ruoyi-admin.jar app.jar
EXPOSE  80  8090 81
ENTRYPOINT /bin/sh -c   /etc/init.d/start.sh

#启动脚本
#docker rmi `docker images|grep none| awk '{print $3}'`

#docker build -t docker.xt.wenhq.top:8083/docker_r/yjzh_test:1.0 .
#docker run --privileged=true  -itd --name yjzh_test -v /sys/fs/cgroup:/sys/fs/cgroup:ro  -p 81:81 -p 8080:8080 -p 82:80  959e5d6a26e7

# 删除镜像
#curl -I -X DELETE http://docker.xt.wenhq.top:8083/v2/docker_r/yjzh_test/manifests/sha256:af0a8819
