Dockerfile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #https://blog.csdn.net/sinat_19528249/article/details/99994464
  2. # Version 0.1
  3. # 基础镜像
  4. FROM centos:7
  5. # 维护者信息
  6. MAINTAINER kangxiaolin ksf@zgykkj.com
  7. VOLUME /tmp
  8. #自动安装依赖
  9. RUN cd /etc/yum.repos.d/ \
  10. && yum -y install wget \
  11. && wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo \
  12. && yum clean all \
  13. && yum makecache \
  14. && yum update -y \
  15. && yum -y install nginx \
  16. && yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel \
  17. && yum -y install redis \
  18. #这里可以设置 域名
  19. # 可以送本地加载 使用ADD 也可以直接写
  20. && echo "server { \
  21. listen 81; \
  22. location ^~ /jeecg-boot { \
  23. proxy_pass http://127.0.0.1:8080/jeecg-boot/; \
  24. proxy_set_header Host 127.0.0.1; \
  25. proxy_set_header X-Real-IP \$remote_addr; \
  26. proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; \
  27. } \
  28. #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 \
  29. location / { \
  30. root /var/www/html/; \
  31. index index.html index.htm; \
  32. if (!-e \$request_filename) { \
  33. rewrite ^(.*)\$ /index.html?s=\$1 last; \
  34. break; \
  35. } \
  36. } \
  37. access_log /var/log/nginx/access.log ; \
  38. } " > /etc/nginx/conf.d/default.conf \
  39. # 设置启动脚本
  40. && touch /etc/init.d/start.sh \
  41. && touch jeecgboot.log \
  42. && chmod +x /etc/init.d/start.sh \
  43. && echo "#!/bin/bash " >> /etc/init.d/start.sh \
  44. && echo "/usr/bin/redis-server & " >> /etc/init.d/start.sh \
  45. && echo "/usr/sbin/nginx -c /etc/nginx/nginx.conf" >> /etc/init.d/start.sh \
  46. && echo " java -jar /jeecgboot.jar " >> /etc/init.d/start.sh \
  47. && mkdir -p /var/www \
  48. && mkdir -p /var/www/html
  49. # 前端迁移到系统文件中 默认是80端口 同级目录下的html地址
  50. ADD ant-design-vue-jeecg/dist/ /var/www/html/
  51. # 拷贝相关的jar包
  52. ADD jeecg-boot/jeecg-boot-module-system/target/jeecg-boot-module-system-2.1.4.jar jeecgboot.jar
  53. EXPOSE 80 8080 81
  54. ENTRYPOINT /bin/sh -c /etc/init.d/start.sh
  55. #启动脚本
  56. #docker rmi $(docker images | grep "^<none>" | awk "{print $3}") 删除<none>
  57. #docker build -t jeecgboot:centos .
  58. #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