1. 下载安装包
mkdir -p /root/docker/davinci/software && cd /root/docker/davinci/software
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. 应用配置文件准备
rm -rf /root/docker/davinci/config/application.yml
vi /root/docker/davinci/config/application.yml
内容如下:
server:
protocol: http
address: 172.16.0.179
port: 8080
servlet:
context-path: /
jwtToken:
secret: secret
timeout: 1800000
algorithm: HS512
source:
initial-size: 1
min-idle: 1
max-wait: 30000
max-active: 10
break-after-acquire-failure: true
connection-error-retry-attempts: 1
time-between-eviction-runs-millis: 2000
min-evictable-idle-time-millis: 600000
max-evictable-idle-time-millis: 900000
test-while-idle: true
test-on-borrow: false
test-on-return: false
validation-query: select 1
validation-query-timeout: 10
keep-alive: false
filters: stat
enable-query-log: false
result-limit: 1000000
spring:
mvc:
async:
request-timeout: 30s
rest:
proxy-host:
proxy-port:
proxy-ignore:
## davinci datasource config
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://172.16.0.6:3306/davincidb?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
initial-size: 1
min-idle: 1
max-wait: 30000
max-active: 10
break-after-acquire-failure: true
connection-error-retry-attempts: 1
time-between-eviction-runs-millis: 2000
min-evictable-idle-time-millis: 600000
max-evictable-idle-time-millis: 900000
test-while-idle: true
test-on-borrow: false
test-on-return: false
validation-query: select 1
validation-query-timeout: 10
keep-alive: false
filters: stat
## redis config
redis:
isEnable: false
## standalone config
host: 127.0.0.1
port: 6379
password:
database: 0
timeout: 1000
jedis:
pool:
max-active: 8
max-wait: 1
max-idle: 8
min-idle: 0
mail:
host:
port:
username:
fromAddress:
password:
nickname:
properties:
smtp:
starttls:
enable: true
required: true
auth: true
mail:
smtp:
ssl:
enable: false
ldap:
urls:
username:
password:
base:
domainName:
security:
oauth2:
enable: false
screenshot:
default_browser: CHROME
timeout_second: 600
chromedriver_path: $your_chromedriver_path$
remote_webdriver_url: $your_remote_webdriver_url$
data-auth-center:
channels:
- name:
base-url:
auth-code:
statistic:
enable: false
elastic_urls:
elastic_user:
elastic_index_prefix:
mysql_url:
mysql_username:
mysql_password:
kafka.bootstrap.servers:
kafka.topic:
java.security.krb5.conf:
java.security.keytab:
java.security.principal:
encryption:
maxEncryptSize: 1024
type: Off
修改如下:
- server.address:配置为容器IP(默认:127.0.0.1,无法将8080端口暴露出去)。
- spring.datasource:配置MySQL相关信息。
2. 初始化库表准备
附件:davinci_for_mysql-5.5.x.sqlmkdir -p /root/docker/davinci/init
rm -rf /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql
# 对于MySQL-5.6以下版本,需要修改初始化SQL文件(ON UPDATE)
vi /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql
sudo docker cp /root/docker/davinci/init/davinci_for_mysql-5.5.x.sql mysql:/usr/local/include/
docker exec -it mysql bash
mysql -P 3306 -h localhost -u root -proot < /usr/local/include/davinci_for_mysql-5.5.x.sql
3. 编写Dockfile
内容如下: ```bash FROM openjdk:8u242-jdk AS baserm -rf /root/docker/davinci/Dockerfile
vi /root/docker/davinci/Dockerfile
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”]
<a name="1sBs5"></a>
# 4. 构建镜像
```bash
cd /root/docker/davinci
sudo docker build -t="polaris/davinci:v0.3.0-rc" .
# 镜像大小:(JRE8-653MB,OpenJDK8-851MB,JDK8-985MB)
sudo docker images | grep polaris/davinci
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 UI:http://ltsr003:58080 (guest@davinci.cn / 123456,参考:davinci_for_mysql-5.5.x.sql)