Merge pull request #29 from 0x00Geek/master

Provide the support of docker deployment
This commit is contained in:
Li, Zeng 2018-06-06 13:55:45 +08:00 committed by GitHub
commit 8e8395ff0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 159 additions and 0 deletions

35
Dockerfile Normal file
View File

@ -0,0 +1,35 @@
#This Dockerfile is just a primitive one. We welcome optimization and simplification.
#Attention:
It is best to update the process of modification in the rear of the original code(reduce the order changes).
Otherwise the speed of construction will be influenced on a large scale.
#TODO: some space can be saved by using the low version of gcc mirror(e.g-gcc:5).
But its mobility and dependence has not been tested yet and waiting for confirmation.
FROM gcc:8
#download all the optional installation library in gstore's document.
RUN apt-get update && apt-get install -y --no-install-recommends realpath \
ccache \
openjdk-8-jdk \
libreadline-dev \
libboost-all-dev \
&& rm -rf /var/lib/apt/lists/
COPY . /usr/src/gstore
WORKDIR /usr/src/gstore
#ENV CC="ccache gcc" CXX="ccache g++"? should not be choosed.
Because it will trigger extremely troublesome bugs and its reason is still waiting for checking.
#The solution to the problem of java, whose default setting is using ansii to encode.
ENV LANG C.UTF-8
#Make compiling will be executed or replaced automatically when the container launch.
notice: RUN make still has some problems now.
#Subsequent test version can be put here.
And some procedures you need can also be attached here.
CMD ["make"]

View File

@ -0,0 +1,62 @@
# Deploy gStore by Docker
[点击查看中文文档](Docker方式部署gStore.md)
>Roughly speaking, there are two ways to deploy gStore via Docker.
>
>The first one is using Dockerfile file in the root directory of project to automatically build it. And then run the container to compile automatically(make).
>
>Another one is downloading the mirror which has been built directly, then just run it.
## 0x00. prepare the environment
Official doc of Docker has explained how to download and use it on common Liunx release version in details. And here is the link: [English doc](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [中文文档](https://docs.docker-cn.com/engine/installation/linux/docker-ce/centos/#%E5%85%88%E5%86%B3%E6%9D%A1%E4%BB%B6)
It's worth noting that the Docker with too high version may lead to some problems. Please read the precautions carefully. The current version of test environment is <u>Docker CE 17.04</u>
## 0x01. Build the mirror via Dockerfile
After having the correct Docker environment and network, use `git clone` to download the project firstly. Then enter the root directory and modify the `CC = gcc`(official setting) into `CC = ccache g++` in the makefile file. After inputting command `docker build -t gstore` it's available to start building. In the default case, it will use the Dockerfile in the root directory. More specific explanation has been written in the Dockerfile.
After the building, using `docker run -it gstore` directly to enter the container. It will trigger make to compile automatically. Other operation can be executed after finishing all the procedure shown above. The subsequent document is waiting for completing. (The reason why we didn't merge the make to the building process is that it will trigger exception)
## 0x02. pulling the mirror directly to run
Instead of downloading project or building on your own, input `docker pull imbajin/test:gs` to pull the mirror which has been built well by the Dockerfile. But the make hasn't been executed yet. Then input `docker run -it imbajin/test:gs` to compile, which will cost 5 to 10 minutes or so. (You could add alias to the container in the sake of convenience)
Another optional version we provided is `docker pull imbajin/test:gsmake` . This mirror will protect the status after the completion of make, which is out of box after your pulling. It's a ideal one and its still waiting for test(just for reference).
*PS: The repository is personally maintained now, it will be handed over to the team to maintain later(including automatic build)*
## 0x03. Problems that exist
Owing to the uncertain influence accompanying the containerization, including but not limited to some problems about network, lock, caching, rights and so on, it's quite difficult to locate the problem when debugging. It has been known that the following problems may exist: (The host is Centos 7.4)
1. If execute the make command directly in the container straightforward, the last execution of the testall script will fill up the temporary space, resulting in interruption. (The specific reason is being investigated)
2. Strange tar command error occurred when associating Dockerhub automatic building via Dockerfile. See this [address](https://hub.docker.com/r/imbajin/docker/builds/b3rwguoffywc6equeajyg7g/)(reason is waiting for investigation)
3. If add the environment `ENV CC="ccache g++"` in the process of Dockerfile building, it will lead to compile error. The reason is still unknown and it may affect the mirror cache layer, which results in repeated errors in the later process of building.
4. The case of shutdown automatically as soon as its reboot may occur after starting the container via docker run.
## 0x04. Follow-up
### A. Performance testing
The proportion of the loss of the performance of the container under the conditions of different file numbers/networks. The performance of running gStore in the native environment and in the container.
It's waiting for supplement.
### B. Test of connecting other containers
Waiting for supplement.
### C. Simplification and optimization of building
The mirror of gcc:8 has conquered the space of 1.7G, bringing a lot of unnecessary things(including the environment of Go). Hoping to optimize the mirror source in the future excepting lowing the gcc's version.
---
There are still a large number of content waiting for supplement.
Up to now we have just given a basic version. It's only the first step of containerization.
It's the document ver1.0

View File

@ -0,0 +1,62 @@
# Docker方式部署gStore中文
> 简单说我们提供两种方式通过容器部署gStore
>
> 一种是通过项目根目录的Dockerfile文件自主构建然后运行容器自动编译(make).
>
> 另一种是直接下载已经构建完成的镜像,然后直接运行.
## 0x00.环境准备
关于安装使用Docker官方针对常见Linux发行版文档已经写得很详细就直接给出参考地址[英文文档](https://docs.docker.com/install/linux/docker-ce/ubuntu/)[中文文档](https://docs.docker-cn.com/engine/installation/linux/docker-ce/centos/#%E5%85%88%E5%86%B3%E6%9D%A1%E4%BB%B6) 。
需要注意的是Docker版本过高可能导致一些问题建议仔细阅读注意事项。当前测试环境版本是<u>Docker CE 17.04</u>
## 0x01.通过Dockerfile构建镜像
假设已经拥有正常的Docker环境跟网络后首先通过`git clone ` 下载项目,然后进入项目根目录,**修改**根目录的makefile文件的`CC = ccache g++` (*建议官方改回这个默认*),输入命令`docker build -t gstore .` 即可开始构建默认使用根目录的Dockerfile关于具体说明Dockerfile文件内也有补充。
构建完成后,直接通过`docker run -it gstore` 即可进入容器自动触发make进行编译。完成后即可执行其他操作后续待文档完善。之所以未将make并入构建过程是因为触发了异常
## 0x02.直接拉取镜像运行
无需下载项目或自己构建,直接输入`docker pull imbajin/test:gs` 拉取已经通过Dockerfile构建完成的镜像但是没有执行make 。拉取完成后 `docker run -it imbajin/test:gs ` 即可进入编译耗时大概要5~10分钟。您可以给容器添加别名以便方面使用
另外提供一个可选的版本是`docker pull imbajin/test:gsmake` 这个镜像保护make完成后的状态拉取完成后可开箱即用。是未来的理想状态但是尚未具体测试仅供参考。
*<u>补:目前仓库地址为个人维护,后续应会移交团队自行维护(包括自动构建) </u>*
## 0x03.存在的问题
因为容器化伴随着一些不确定的影响,包括不限于网络,锁,缓存,权限等问题,遇到调试起来很难定位,已知可能存在以下问题:(宿主机是Centos7.4)
1. 如果在容器内直接执行make命令最后执行testall脚本会写满临时空间导致中断具体原因排查中
2. 通过Dockerfile关联Dockerhub自动构建时出现了奇怪的tar命令报错[详见地址](https://hub.docker.com/r/imbajin/docker/builds/b3rwguoffywc6equeajyg7g/)末尾。(原因也待查)
3. 在Dockerfile的构建过程中如果添加环境`ENV CC="ccache g++" ` 会导致编译错误,原因未知且可能影响镜像缓存层,导致之后构建反复报错。。
4. 通过docker run启动容器后可能出现启动后即自动关闭的情况。
## 0x04.后续工作
#### A.性能测试
这个待后续补充容器化跟原生运行gStore在不同文件数/网络等情况下,容器的性能损耗具体比重。。
#### B.连接其他容器测试
文档也待后续补充更新,因为目前也是抽空做的
#### C.构建精简优化
因为gcc:8镜像就有1.7G了自带了很多不必要的东西包括go的环境之类的希望后续除了在调低gcc版本之外能对源镜像本身改进出精简版来。
---
其他可能也有不少需要补充,所以目前只是**抛砖引玉**,添加了一个最基本的版本。基本的环境构建只是容器化的第一步,后续工作还不少~ 这只是初版的V1.0文档。