1. 下载安装包

  1. mkdir -p /root/docker/davinci/software && cd /root/docker/davinci/software
  2. wget https://github.com/edp963/davinci/releases/download/v0.3.0-rc/davinci-assembly_0.3.1-0.3.1-SNAPSHOT-dist-rc.zip

2. 准备工作

1. 应用配置文件准备

  1. rm -rf /root/docker/davinci/config/application.yml
  2. vi /root/docker/davinci/config/application.yml

内容如下:

  1. server:
  2. protocol: http
  3. address: 172.16.0.179
  4. port: 8080
  5. servlet:
  6. context-path: /
  7. jwtToken:
  8. secret: secret
  9. timeout: 1800000
  10. algorithm: HS512
  11. source:
  12. initial-size: 1
  13. min-idle: 1
  14. max-wait: 30000
  15. max-active: 10
  16. break-after-acquire-failure: true
  17. connection-error-retry-attempts: 1
  18. time-between-eviction-runs-millis: 2000
  19. min-evictable-idle-time-millis: 600000
  20. max-evictable-idle-time-millis: 900000
  21. test-while-idle: true
  22. test-on-borrow: false
  23. test-on-return: false
  24. validation-query: select 1
  25. validation-query-timeout: 10
  26. keep-alive: false
  27. filters: stat
  28. enable-query-log: false
  29. result-limit: 1000000
  30. spring:
  31. mvc:
  32. async:
  33. request-timeout: 30s
  34. rest:
  35. proxy-host:
  36. proxy-port:
  37. proxy-ignore:
  38. ## davinci datasource config
  39. datasource:
  40. type: com.alibaba.druid.pool.DruidDataSource
  41. url: jdbc:mysql://172.16.0.6:3306/davincidb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
  42. username: root
  43. password: root
  44. driver-class-name: com.mysql.jdbc.Driver
  45. initial-size: 1
  46. min-idle: 1
  47. max-wait: 30000
  48. max-active: 10
  49. break-after-acquire-failure: true
  50. connection-error-retry-attempts: 1
  51. time-between-eviction-runs-millis: 2000
  52. min-evictable-idle-time-millis: 600000
  53. max-evictable-idle-time-millis: 900000
  54. test-while-idle: true
  55. test-on-borrow: false
  56. test-on-return: false
  57. validation-query: select 1
  58. validation-query-timeout: 10
  59. keep-alive: false
  60. filters: stat
  61. ## redis config
  62. redis:
  63. isEnable: false
  64. ## standalone config
  65. host: 127.0.0.1
  66. port: 6379
  67. password:
  68. database: 0
  69. timeout: 1000
  70. jedis:
  71. pool:
  72. max-active: 8
  73. max-wait: 1
  74. max-idle: 8
  75. min-idle: 0
  76. mail:
  77. host:
  78. port:
  79. username:
  80. fromAddress:
  81. password:
  82. nickname:
  83. properties:
  84. smtp:
  85. starttls:
  86. enable: true
  87. required: true
  88. auth: true
  89. mail:
  90. smtp:
  91. ssl:
  92. enable: false
  93. ldap:
  94. urls:
  95. username:
  96. password:
  97. base:
  98. domainName:
  99. security:
  100. oauth2:
  101. enable: false
  102. screenshot:
  103. default_browser: CHROME
  104. timeout_second: 600
  105. chromedriver_path: $your_chromedriver_path$
  106. remote_webdriver_url: $your_remote_webdriver_url$
  107. data-auth-center:
  108. channels:
  109. - name:
  110. base-url:
  111. auth-code:
  112. statistic:
  113. enable: false
  114. elastic_urls:
  115. elastic_user:
  116. elastic_index_prefix:
  117. mysql_url:
  118. mysql_username:
  119. mysql_password:
  120. kafka.bootstrap.servers:
  121. kafka.topic:
  122. java.security.krb5.conf:
  123. java.security.keytab:
  124. java.security.principal:
  125. encryption:
  126. maxEncryptSize: 1024
  127. type: Off

修改如下:

  • server.address:配置为容器IP(默认:127.0.0.1,无法将8080端口暴露出去)。
  • spring.datasource:配置MySQL相关信息。

    2. 初始化库表准备

    1. mkdir -p /root/docker/davinci/init
    2. rm -rf /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql
    3. # 对于MySQL-5.6以下版本,需要修改初始化SQL文件(ON UPDATE)
    4. vi /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql
    附件:davinci_for_mysql-5.5.x.sql
    1. sudo docker cp /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql mysql:/usr/local/include/
    2. docker exec -it mysql bash
    3. mysql -P 3306 -h localhost -u root -proot < /usr/local/include/davinci_for_mysql-5.5.x.sql

    3. 编写Dockfile

    1. rm -rf /root/docker/davinci/Dockerfile
    2. vi /root/docker/davinci/Dockerfile
    内容如下: ```bash FROM openjdk:8u242-jdk AS base

LABEL MAINTAINER=”450733605@qq.com”

WORKDIR /opt

ADD software/davinci-assembly_0.3.1-0.3.1-SNAPSHOT-dist-rc.zip /opt/

RUN cd /opt \ && unzip davinci-assembly_0.3.1-0.3.1-SNAPSHOT-dist-rc.zip -d /opt/ \ && mv davinci-assembly_0.3.1-0.3.1-SNAPSHOT-dist-rc davinci \ && rm -rf /opt/davinci-assembly_0.3.1-0.3.1-SNAPSHOT-dist-rc.zip \ && rm -rf /opt/davinci/bin/davinci.sql

ADD bin/docker-entrypoint.sh /opt/davinci/bin/docker-entrypoint.sh

ADD config/application.yml /opt/davinci/config/application.yml ADD init/davinci_for_mysql-5.5.x.sql /opt/davinci/bin/davinci.sql

ENV DAVINCI3_HOME /opt/davinci

WORKDIR /opt/davinci

EXPOSE 8080

CMD [“./bin/start-server.sh”]

  1. <a name="1sBs5"></a>
  2. # 4. 构建镜像
  3. ```bash
  4. cd /root/docker/davinci
  5. sudo docker build -t="polaris/davinci:v0.3.0-rc" .
  6. # 镜像大小:(JRE8-653MB,OpenJDK8-851MB,JDK8-985MB)
  7. sudo docker images | grep polaris/davinci
  8. sudo docker rmi polaris/davinci:v0.3.0-rc

5. 容器操作

  • 容器启动

    sudo docker run -itd --name davinci --net bigdata -p 58080:8080 \
    --ip 172.16.0.179 \
    -e SPRING_DATASOURCE_URL="jdbc:mysql://172.16.0.6:3306/davincidb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" \
    -e SPRING_DATASOURCE_USERNAME="root" \
    -e SPRING_DATASOURCE_PASSWORD="root" \
    -e SPRING_MAIL_HOST="smtp.qq.com" \
    -e SPRING_MAIL_PORT="465" \
    -e SPRING_MAIL_PROPERTIES_MAIL_SMTP_SSL_ENABLE="true" \
    -e SPRING_MAIL_USERNAME="450733605@qq.com" \
    -e SPRING_MAIL_PASSWORD="ktzwkmykjrbpbjjc" \
    -e SPRING_MAIL_NICKNAME="davinci_sys" \
    polaris/davinci:v0.3.0-rc
    
  • 基本操作 ```bash sudo docker ps -a |grep davinci

查看端口暴露情况

sudo docker inspect davinci| grep IPAddress sudo docker port davinci sudo iptables -t nat -nvL —line-number| grep 172.16.0.179

容器操作

sudo docker start davinci sudo docker restart davinci sudo docker stop davinci sudo docker rm davinci

<a name="fYckM"></a>
# 6. 验证
```bash
docker exec -it davinci bash
ps -ef | grep java | grep edp.DavinciServerApplication 
sudo docker logs davinci
curl http://ltsr003:58080/index.html

Web UIhttp://ltsr003:58080 (guest@davinci.cn / 123456,参考:davinci_for_mysql-5.5.x.sql)