Davinci one-touch deployment | on how to run Davinci with three sentences of code

  docker

Source: Agile Big Data

Author: Tang Bosheng

Yixin Institute of Technology

 

Introduction: Before, the small partners who liked Davinci needed to wait for the technicians’ answers in github issue area when they encountered problems in installation and deployment of Davinci. Don’t be afraid now. The enthusiastic user of the community, Pak Kiu-jun, has helped us to start with the docker-composer key. With only a few lines of code in the future, Davinci will be able to run smoothly. What are you waiting for, hurry up and deploy it ~

Knock on the point

The original davincidoc deployment tutorial is here:

https://github.com/edp963/dav …

It will be updated from time to time.

Remember to collect! !

The following is a deployment tutorial:

I. Environmental Requirements

Windows, linux, mac after docker Installed.

Check if there is a docker-compose command (it will be available by default after installing docker, otherwise please install it manually).

II. Complete Steps

git clone https://github.com/edp963/davinci-docker.git
cd /d davinci-docker
# docker build -t="edp963/davinci:v0.3.0-beta.4" .
# 修改docker-compose.yml中邮箱配置docker-compose up -d 复制代码

Done!

You are right!

It was so simple!

In this way, Davinci can be installed and deployed!

Don’t worry about problems when installing Davinci anymore!

However, goose, what did our Chinese cabbage monarch think during the process of deploying Docker mirror image? Let’s continue to look down:

The content will be updated from time to time, so please collect this address:

https://github.com/edp963/dav …

Three, Docker support environment variable list

图片描述

Fourth, principle analysis

Make davincidoc mirror image

1. docfileanalysis

FROM java:8-jre
LABEL MAINTAINER="edp_support@groups.163.com"
# 从github上下载分发包并解压
RUN cd / \ 
&& mkdir -p /opt/davinci\ 
&& wget
https://github.com/edp963/davinci/releases/download/v0.3.0-beta.4/davinci-assembly_3.0.1-0.3.0-SNAPSHOT-dist-beta.4.zip
\  && unzip
davinci-assembly_3.0.1-0.3.0-SNAPSHOT-dist-beta.4.zip -d /opt/davinci
# 将phantomjs打包到镜像
ADD phantomjs-2.1.1 /opt/phantomjs-2.1.1
# 数据库初始化脚本,等待数据库就绪后启动spring boot
ADD bin/start.sh /opt/davinci/bin/start.sh
# docker镜像是静态的,因此配置文件中的配置需要用环境变量传递,详见12factor# https://12factor.net/zh_cn/
ADD config/application.yml
/opt/davinci/config/application.yml
# 预设davinci必备的两个环境变量ENV
DAVINCI3_HOME /opt/davinciENV PHANTOMJS_HOME /opt/phantomjs-2.1.1
WORKDIR /opt/davinci
# 为什么使用CMD而不是ENTRYPOINT? 因为CMD可以在docker run的时候被替代# 在使用compose或K8S时,很有可能要在启动前执行其它脚本,而不是直接运行# start-server.sh# 在单独docker run且不附加任何命令时,以下命令默认执行
CMD ["./bin/start-server.sh"]
EXPOSE 8080复制代码

start.sh

#!/bin/bash
# 将sql脚本经过mysql8兼容处理后,写入/initdb目录# /initdb 目录是与mysql容器共享目录# mysql容器将在启动时执行 /docker-entrypoint-initdb.d 中的所有脚本
cd /opt/davinci/bin/mkdir /initdbcat
davinci.sql > /initdb/davinci.sqlsed -i '1i\SET
GLOBAL log_bin_trust_function_creators = 1;' /initdb/davinci.sql
 
# 由于docker compose中启动顺序管理交给了容器自己# 详见
https://docs.docker.com/compose/startup-order/# 因此我们需要用curl探测mysql端口,当接受数据字节大于0时认为# 数据库可以连通,接下来我们执行davinci spring boot主程序set
-e
host="$1"shiftcmd="$@"
until [ $(curl -I -m 10 -o /dev/null -s -w %{size_download} $host) -gt 0 ]; do  >&2 echo
"database is unavailable - sleeping"  sleep 1done
source $cmd复制代码

2, build a mirror image

docker build -t="edp963/davinci:v0.3.0-beta.4" .复制代码

3、 Docker Compose

version: '3.6'services:  davinci:   
environment:      - MYSQL_CONN=jdbc:mysql://mysql:3306/davinci0.3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true      - DB_USER=root      - DB_PWD=abc123123      - MAIL_HOST=smtp.163.com      - MAIL_PORT=465      - MAIL_STMP_SSL=true      - MAIL_USER=xxxxxx@163.com      - MAIL_PWD=xxxxxxxx      - MAIL_NICKNAME=davinci    image: "edp963/davinci:v0.3.0-beta.4"    ports:     
- 58080:8080    # 等待mysql就绪后再启动spring boot主程序    command: ["./bin/start.sh",
"mysql:3306", "--", "start-server.sh"]    restart: always    volumes:      - davinci_logs:/opt/davinci/logs      - davinci_userfiles:/opt/davinci/userfiles      - davinci_initdb:/initdb  #共享给mysql作数据初始化  mysql:    image: mysql:8    restart: always    environment:      - MYSQL_ROOT_PASSWORD=abc123123      - MYSQL_DATABASE=davinci0.3    volumes:      - mysql_data:/var/lib/mysql      # 初始化脚本源自davinic容器的initdb目录      - davinci_initdb:/docker-entrypoint-initdb.d:ro   
volumes:  davinci_userfiles:  davinci_logs: 
davinci_initdb:  mysql_data:复制代码

Tip: docker-compose.yml environment variable configuration K=V cannot contain spaces and V cannot be enclosed in double quotes

4. dockercomposite startup

docker-compose up -d 复制代码

5. Docker only startup (using external database)

docker run -p 58081:8080 -e MYSQL_CONN="jdbc:mysql://yourmysqlserver:3306/davinci0.3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" \
-e DB_USER="root" -e DB_PWD="pwd" \
-e MAIL_HOST="smtp.163.com"
-e MAIL_PORT="465"
-e MAIL_STMP_SSL="true" \
-e MAIL_USER="xxxxxx@163.com"  
-e MAIL_PWD="xxxxxxx" \
-e MAIL_NICKNAME="davinci_sys" \
edp963/davinci:v0.3.0-beta.4复制代码

6. Use richer configurations

You can add some configuration files to the host to view the davinci configuration:https://github.com/edp963/dav …

Then mount it to /opt/davinci/config when docker run.

docker run -p 58081:8080 -e MYSQL_CONN="jdbc:mysql://yourmysqlserver:3306/davinci0.3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" \
-e DB_USER="root" -e DB_PWD="pwd" \
-e MAIL_HOST="smtp.163.com"  -e MAIL_PORT="465" -e MAIL_STMP_SSL="true" \
-e MAIL_USER="xxxxxx@163.com"  -e MAIL_PWD="xxxxxxx" \
-e MAIL_NICKNAME="davinci_sys" \
-v/etc/davinci:/opt/davinci/config \
edp963/davinci:v0.3.0-beta.4