导读:之前喜欢 Davinci 的小伙伴儿在安装部署 Davinci 遇见问题时需要在 github issue 区等待技术人员的解答。现在不用怕啦,社区热心用户白菜君帮我们支持了 docker-composer 一键启动,以后只需寥寥几行代码,Davinci 就能舒畅的 run 起来了。还等什么,赶紧部署起来吧~
敲重点
Davinci Docker 原部署教程在这里:
https://github.com/edp963/davinci-docker
里面会不定时更新
记得收藏啊!!
下面是部署教程:
一、环境要求
安装 docker 后的 windows, linux, mac。
检查是否有 docker-compose 命令(安装 docker 后默认会有,否则请手动安装)。
二、完整步骤
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>git clone https:``//github.com/edp963/davinci-docker.git<br>cd /d davinci-docker<br># docker build -t="edp963/davinci:v0.3.0-beta.4" .<br># 修改docker-compose.yml中邮箱配置docker-compose up -d<br></span> |
完成!
你没看错!
就这么简单的完成了!
这样就可以安装部署 Davinci 了!
再也不用担心安装 Davinci 时遇到问题了!
然鹅,在部署 Docker 镜像过程中,我们的白菜君是怎么想的呢?让我们继续往下看:
内容会不定时更新哦,所以请大家收藏这个地址:
https://github.com/edp963/davinci-docker
三、Docker 支持环境变量列表
四、原理分析
制作 Davinci Docker 镜像
Dockfile 分析
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>FROM java:``8``-jre<br>LABEL MAINTAINER=``"edp_support@groups.163.com"``<br># 从github上下载分发包并解压<br>RUN cd / \ <br>&& mkdir -p /opt/davinci\ <br>&& wget<br>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<br>\ && unzip<br>davinci-assembly_3.0.1-0.3.0-SNAPSHOT-dist-beta.4.zip -d /opt/davinci<br># 将phantomjs打包到镜像<br>ADD phantomjs-2.1.1 /opt/phantomjs-2.1.1<br># 数据库初始化脚本,等待数据库就绪后启动spring boot<br>ADD bin/start.sh /opt/davinci/bin/start.sh<br># docker镜像是静态的,因此配置文件中的配置需要用环境变量传递,详见12factor# https://12factor.net/zh_cn/<br>ADD config/application.yml<br>/opt/davinci/config/application.yml<br># 预设davinci必备的两个环境变量ENV<br>DAVINCI3_HOME /opt/davinciENV PHANTOMJS_HOME /opt/phantomjs-2.1.1<br>WORKDIR /opt/davinci<br># 为什么使用CMD而不是ENTRYPOINT? 因为CMD可以在docker run的时候被替代# 在使用compose或K8S时,很有可能要在启动前执行其它脚本,而不是直接运行# start-server.sh# 在单独docker run且不附加任何命令时,以下命令默认执行<br>CMD ["./bin/start-server.sh"]<br>EXPOSE 8080<br></span> |
start.sh
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>#!/bin/bash<br># 将sql脚本经过mysql8兼容处理后,写入/initdb目录# /initdb 目录是与mysql容器共享目录# mysql容器将在启动时执行 /docker-entrypoint-initdb.d 中的所有脚本<br>cd /opt/davinci/bin/mkdir /initdbcat<br>davinci.sql > /initdb/davinci.sqlsed -i ``'1i\SET<br>GLOBAL log_bin_trust_function_creators = 1;' /initdb/davinci.sql<br><br># 由于docker compose中启动顺序管理交给了容器自己# 详见<br>https:``//docs.docker.com/compose/startup-order/# 因此我们需要用curl探测mysql端口,当接受数据字节大于0时认为# 数据库可以连通,接下来我们执行davinci spring boot主程序set<br>-e<br>host="$1"shiftcmd="$@"<br>until [ $(curl -I -m 10 -o /dev/null -s -w %{size_download} $host) -gt 0 ]; do >&2 echo<br>"database is unavailable - sleeping" sleep 1done<br>source $cmd<br></span> |
构建镜像
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>docker build -t=``"edp963/davinci:v0.3.0-beta.4" .<br></span> |
Docker Compose
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>version: ``'3.6'``services: davinci: <br>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: <br>- 58080:8080 # 等待mysql就绪后再启动spring boot主程序 command: ["./bin/start.sh",<br>"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 <br>volumes: davinci_userfiles: davinci_logs: <br>davinci_initdb: mysql_data:<br></span> |
小提示:docker-compose.yml 环境变量配置 K=V 中不能出现空格,V 也不能用双引号包裹
Docker Compose 启动
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>docker-compose up -d<br></span> |
仅 Docker 启动(使用外部数据库)
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>docker run -p ``58081``:``8080 -e MYSQL_CONN=``"jdbc:mysql://yourmysqlserver:3306/davinci0.3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" \<br>-e DB_USER=``"root" -e DB_PWD=``"pwd" \<br>-e MAIL_HOST=``"smtp.163.com"``<br>-e MAIL_PORT=``"465"``<br>-e MAIL_STMP_SSL=``"true" \<br>-e MAIL_USER=``"xxxxxx@163.com" <br>-e MAIL_PWD=``"xxxxxxx" \<br>-e MAIL_NICKNAME=``"davinci_sys" \<br>edp963/davinci:v0.``3.0``-beta.``4``<br></span> |
使用更丰富的配置
可以在宿主中添加一些配置文件,查看 davinci 配置:https://github.com/edp963/davinci/tree/master/config
然后 docker run 时将其挂载到 /opt/davinci/config
col 1 | col 2 |
---|---|
1 | <span style=``"font-family: 黑体, SimHei;"``>docker run -p ``58081``:``8080 -e MYSQL_CONN=``"jdbc:mysql://yourmysqlserver:3306/davinci0.3?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true" \<br>-e DB_USER=``"root" -e DB_PWD=``"pwd" \<br>-e MAIL_HOST=``"smtp.163.com" -e MAIL_PORT=``"465" -e MAIL_STMP_SSL=``"true" \<br>-e MAIL_USER=``"xxxxxx@163.com" -e MAIL_PWD=``"xxxxxxx" \<br>-e MAIL_NICKNAME=``"davinci_sys" \<br>-v/etc/davinci:/opt/davinci/config \<br>edp963/davinci:v0.``3.0``-beta.``4``</span> |
本文转载自宜信技术学院网站。
原文链接:http://college.creditease.cn/detail/226
更多内容推荐
【云原生 | Docker】腾讯云部署 Django 项目 (服务器选型、git 配置、docker 三分钟部署)
🤵♂️ 个人主页: @计算机魔术师👨💻 作者简介:CSDN内容合伙人,全栈领域优质创作者。
2022-09-02
12、nginx 应用之日志管理
2023-09-28
终于可以像使用 Docker 一样丝滑地使用 Containerd 了!
单机上也能愉快地使用 Containerd 了
5.Jenkins Security
2023-09-30
无需依赖 Docker 环境制作镜像
随着高版本的Kubernetes弃用Docker,企业也可以不依赖Docker环境了,但是DevOps通过Kubernetes部署的话,仍然需要制作镜像,那么在没有Docker环境的情况下如何制作呢?推荐一款谷歌的开源工具Jib,github地址,它是一个无需Docker守护进程——也无需深入掌握
2023-02-15
2. Jenkins 入门
2023-09-30
KubeSphere 多集群管理大招:使用 QKE 管理多个 ACK 集群
KubeSphere 一举拿下多集群管理和多集群调度
Docker 进阶 dockerfile 指令构建 docker 镜像
Docker进阶 Dockerfile指令,编译dockerfile文件构建镜像,dockerfile常用指令,实操训练:Dockerfile构建Nginx镜像: FROM #指定基础镜像,一切从这里开始构建 MAINTAINER #镜像是谁写的,姓名+邮箱 RUN #镜像构建的时候需要运行的命令
2022-10-31
8. SELECT 进阶:别名
2023-09-26
2. 镜像安全
2023-09-27
Docker daemon configuration overview(Docker 守护进程配置概览)
翻个译
2022-12-28
除了轻量、高效外,Docker 还有什么惊喜你不知道?
当DevOps开发概念逐渐成为主流时,Docker的优势也在不断浮现和增强。
23|实战项目(五):做一个类似 LensaAI 的梦幻照相馆
这一讲,我们会训练出一个能高度还原人像效果的LoRA模型,有了这个模型,你就能实现一个梦幻照相馆的项目。
2023-09-08
配置 containerd 镜像仓库完全攻略
本文将以K3s为例对containerd进行配置,如果您的环境未使用 K3s 而是使用的 Kubernetes,你也可以参考本文来配置 containerd 的镜像仓库,因为 containerd 的配置是通用的。
阿里 sealer 是如何实现整个集群一键交付的?
集群镜像把整个集群看成一台服务器,把 k8s 看成云操作系统,实现整个集群的镜像化打包和交付,为企业级软件提供一种“开箱即用”的应用封装技术。
Relocating the Docker root directory
If the file space in the Docker root directory is not adequate, you must relocate the directory.
2023-02-09
Docker 可视化管理工具 Portainer
Portainer是Docker的图形化管理工具,提供状态显示面板、应用模板快速部署、容器镜像网络数据卷的基本操作(包括上传下载镜像,创建容器等操作)、事件日志显示、容器控制台操作、Swarm集群和服务等集中管理和操作、登录用户管理和控制等功能。
2021-08-07
干货 | Docker 还可以搭建 Web 服务器 nginx ?这么宝藏的吗?
浏览器访问:https://hub.docker.com/_/nginx 查看Nginx镜像详细信息。
2022-09-09
“救世主”Docker
Docker这个“魔术大师”是怎么解决我的问题的?
推荐阅读
课程介绍
2023-10-11
500 行代码手写 docker 开篇 -goland 远程编译环境配置
2023-05-19
24|提示语工程(六):超越智能,让你的 AI 系统成为全知超人
2023-10-13
docker 简介与背景知识
2023-07-23
5.Docker 实战
2023-09-30
2023-11-18:用 go 语言,如果一个正方形矩阵上下对称并且左右对称,对称的意思是互为镜像, 那么称这个正方形矩阵叫做神奇矩阵。 比如 : 1 5 5 1 6 3 3 6 6 3 3 6 1 5
2023-11-18
拿来吧你!保姆级 Docker 底层原理及源码实战手册,上线点赞破 10W
2023-04-24
电子书
大厂实战PPT下载
换一换 黄宇凯 | 海天瑞声 首席技术官兼自动驾驶事业部总经理
伍斌杰 | 京东物流 算法架构师
孙建业 | 作业帮 大数据平台架构负责人
评论