diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 000000000..54c18e038 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,30 @@ +version: '3' +services: + mongo: + image: mongo:latest + container_name: mongo + environment: + - TZ=Asia/Shanghai + - MONGO_INITDB_DATABASE=quantaxis + volumes: + - ./data:/data + ports: + - 27017:27017 +#-- + quantaxis: + build: qa + image: quantaxis:latest + container_name: quantaxis + environment: + - TZ=Asia/Shanghai + - MONGODB=mongo + volumes: + - ./_data_:/data + - ./_notebooks_:/home + ports: + - 8010:8888 + - 8888:8888 + depends_on: + - mongo + links: + - mongo diff --git a/docker/dockerfile b/docker/dockerfile deleted file mode 100755 index 6cd46d726..000000000 --- a/docker/dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM jupyter/base-notebook -MAINTAINER yutiansut 'yutiansut@qq.com' - - -# 修改docker的时区 -RUN apt update \ - && apt install tzdata \ - && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && apt install python3-tk \ - && pip install pip -U -i https://pypi.doubanio.com/simple \ - && pip install -r https://raw.githubusercontent.com/yutiansut/QUANTAXIS/master/requirements.txt -i https://pypi.doubanio.com/simple \ - && pip install tushare \ - && pip install pytdx \ - && pip install quantaxis - - - -EXPOSE 8888 diff --git a/docker/mongo.sh b/docker/mongo.sh deleted file mode 100644 index f5666dbcf..000000000 --- a/docker/mongo.sh +++ /dev/null @@ -1 +0,0 @@ -docker build -t="quantaxis/mongodb" .\mongo\dockerfile \ No newline at end of file diff --git a/docker/mongo/dockerfile b/docker/mongo/dockerfile deleted file mode 100644 index 7aee2df09..000000000 --- a/docker/mongo/dockerfile +++ /dev/null @@ -1,91 +0,0 @@ -FROM debian:jessie-slim - -# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added -RUN groupadd -r mongodb && useradd -r -g mongodb mongodb - -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - ca-certificates \ - jq \ - numactl \ - && rm -rf /var/lib/apt/lists/* - -# grab gosu for easy step-down from root (https://github.com/tianon/gosu/releases) -ENV GOSU_VERSION 1.10 -# grab "js-yaml" for parsing mongod's YAML config files (https://github.com/nodeca/js-yaml/releases) -ENV JSYAML_VERSION 3.10.0 - -RUN set -ex; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - wget \ - ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \ - wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \ - wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \ - gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \ - rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \ - chmod +x /usr/local/bin/gosu; \ - gosu nobody true; \ - \ - wget -O /js-yaml.js "https://github.com/nodeca/js-yaml/raw/${JSYAML_VERSION}/dist/js-yaml.js"; \ -# TODO some sort of download verification here - \ - apt-get purge -y --auto-remove wget - -RUN mkdir /docker-entrypoint-initdb.d - -ENV GPG_KEYS \ -# pub 4096R/91FA4AD5 2016-12-14 [expires: 2018-12-14] -# Key fingerprint = 2930 ADAE 8CAF 5059 EE73 BB4B 5871 2A22 91FA 4AD5 -# uid MongoDB 3.6 Release Signing Key - 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 -# https://docs.mongodb.com/manual/tutorial/verify-mongodb-packages/#download-then-import-the-key-file -RUN set -ex; \ - export GNUPGHOME="$(mktemp -d)"; \ - for key in $GPG_KEYS; do \ - gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \ - done; \ - gpg --export $GPG_KEYS > /etc/apt/trusted.gpg.d/mongodb.gpg; \ - rm -r "$GNUPGHOME"; \ - apt-key list - -# Allow build-time overrides (eg. to build image with MongoDB Enterprise version) -# Options for MONGO_PACKAGE: mongodb-org OR mongodb-enterprise -# Options for MONGO_REPO: repo.mongodb.org OR repo.mongodb.com -# Example: docker build --build-arg MONGO_PACKAGE=mongodb-enterprise --build-arg MONGO_REPO=repo.mongodb.com . -ARG MONGO_PACKAGE=mongodb-org -ARG MONGO_REPO=repo.mongodb.org -ENV MONGO_PACKAGE=${MONGO_PACKAGE} MONGO_REPO=${MONGO_REPO} - -ENV MONGO_MAJOR 3.6 -ENV MONGO_VERSION 3.6.5 - -RUN echo "deb http://$MONGO_REPO/apt/debian jessie/${MONGO_PACKAGE%-unstable}/$MONGO_MAJOR main" | tee "/etc/apt/sources.list.d/${MONGO_PACKAGE%-unstable}.list" - -RUN set -x \ - && apt-get update \ - && apt-get install -y \ - ${MONGO_PACKAGE}=$MONGO_VERSION \ - ${MONGO_PACKAGE}-server=$MONGO_VERSION \ - ${MONGO_PACKAGE}-shell=$MONGO_VERSION \ - ${MONGO_PACKAGE}-mongos=$MONGO_VERSION \ - ${MONGO_PACKAGE}-tools=$MONGO_VERSION \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /var/lib/mongodb \ - && mv /etc/mongod.conf /etc/mongod.conf.orig - -RUN mkdir -p /data/db /data/configdb \ - && chown -R mongodb:mongodb /data/db /data/configdb -VOLUME /data/db /data/configdb - -COPY docker-entrypoint.sh /usr/local/bin/ -ENTRYPOINT ["docker-entrypoint.sh"] - -EXPOSE 27017 -CMD ["mongod"] \ No newline at end of file diff --git a/docker/qa/Dockerfile b/docker/qa/Dockerfile new file mode 100755 index 000000000..962a1d116 --- /dev/null +++ b/docker/qa/Dockerfile @@ -0,0 +1,17 @@ +FROM jupyter/base-notebook +MAINTAINER yutiansut 'yutiansut@qq.com' +MAINTAINER hexj 'hexj001@qq.com' +USER root +COPY source.list /etc/apt/sources.list +# 修改docker的时区 +RUN sudo apt update -y \ + && apt install -y tzdata \ + && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN sudo apt install -y python3-tk +# RUN pip install pip -U -i https://pypi.doubanio.com/simple +RUN pip install -i https://pypi.doubanio.com/simple --upgrade pip +USER jovyan +RUN pip install -r https://raw.githubusercontent.com/yutiansut/QUANTAXIS/master/requirements.txt -i https://pypi.doubanio.com/simple +RUN pip install tushare pytdx quantaxis + +EXPOSE 8888 diff --git a/docker/qa/source.list b/docker/qa/source.list new file mode 100644 index 000000000..ed01179f7 --- /dev/null +++ b/docker/qa/source.list @@ -0,0 +1,13 @@ +# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 +deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse +# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse +deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse +# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse +deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse +# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse +deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse +# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse + +# 预发布软件源,不建议启用 +# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse +# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse \ No newline at end of file diff --git a/docker/readme.md b/docker/readme.md old mode 100755 new mode 100644 index 939170a6c..f292c0058 --- a/docker/readme.md +++ b/docker/readme.md @@ -1,92 +1,35 @@ -# 使用Docker建立QUANTAXIS执行环境 - - - -- [使用Docker建立QUANTAXIS执行环境](#使用docker建立quantaxis执行环境) - - [QUANTAXIS的镜像](#quantaxis的镜像) - - [1.获取QUANTAIS镜像](#1获取quantais镜像) - - [1.1 执行以下命令获取镜像(2选1)](#11-执行以下命令获取镜像2选1) - - [1.2 运行镜像](#12-运行镜像) - - [在浏览器中打开以下链接](#在浏览器中打开以下链接) - - [其他注意选项](#其他注意选项) - - - - -## QUANTAXIS的镜像 - -quantaxis/quantaxis - -## 1.获取QUANTAIS镜像 - -首先,到[docker网站](https://www.docker.com/)下载相应的版本,并创建账号(注意:登录docker账号才能下载镜像) - -(如果国外网站下载速度过慢,windows版本的docker安装文件群共享有) - - -### 1.1 执行以下命令获取镜像(2选1) - - -```shell - -docker pull quantaxis/quantaxis - +docker image for QUANTAXIS: https://github.com/QUANTAXIS/QUANTAXIS +## deployment: +1. start up ``` - - -![执行时的命令行](http://pic.yutiansut.com/QQ%E6%88%AA%E5%9B%BE20171213102629.png) - - -### 1.2 运行镜像 - +docker-compose up ``` -docker run -it -e GRANT_SUDO=yes --user root -p 8080:8080 quantaxis/quantaxis bash +2. initialization #TODO -jupyter notebook --allow-root -(jupyter notebook 密码是 quantaxis) ``` - - - - -### 在浏览器中打开以下链接 -```angular2html - -http://localhost:8888 -``` - - -### 其他注意选项 - -1. docker 是可以通过ssh 连接的 ``` /etc/init.d/ssh start ``` -2. 多窗口 - -首先需要运行一个docker - + docker exec -it CONTAINERNAME base + mkdir FOLDER + cd FOLDER + quantaxis + save all ``` -A:\quantaxis [master ≡] -λ docker run -it -p 8080:8080 quantaxis/quantaxis bash -root@f22b5357dc6e:/# +## stop/remove container: ``` -然后在别的命令行执行 ``` docker ps``` 查询正在运行的docker的container_id +1. docker-compose stop +2. docker-compose rm ``` -A:\Users\yutia -λ docker ps - - -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -f22b5357dc6e quantaxis "bash" 21 seconds ago Up 20 seconds 0.0.0.0:8888->8888/tcp boring_panini +## update: ``` -然后执行 ```docker exec -it [CONTAINERID] /bin/bash``` 进入 - +1. rename the 'image' name for qa service in docker-compose +2. docker-compose up -d ``` -A:\Users\yutia -λ docker exec -it f22b5357dc6e /bin/bash -root@f22b5357dc6e:/# +## database backup: +``` +1. docker-compose stop +2. ./data/db 为mongo数据文件 + ./notebooks 为 程序文件 ``` - - diff --git a/docker/readme_old.md b/docker/readme_old.md new file mode 100755 index 000000000..939170a6c --- /dev/null +++ b/docker/readme_old.md @@ -0,0 +1,92 @@ +# 使用Docker建立QUANTAXIS执行环境 + + + +- [使用Docker建立QUANTAXIS执行环境](#使用docker建立quantaxis执行环境) + - [QUANTAXIS的镜像](#quantaxis的镜像) + - [1.获取QUANTAIS镜像](#1获取quantais镜像) + - [1.1 执行以下命令获取镜像(2选1)](#11-执行以下命令获取镜像2选1) + - [1.2 运行镜像](#12-运行镜像) + - [在浏览器中打开以下链接](#在浏览器中打开以下链接) + - [其他注意选项](#其他注意选项) + + + + +## QUANTAXIS的镜像 + +quantaxis/quantaxis + +## 1.获取QUANTAIS镜像 + +首先,到[docker网站](https://www.docker.com/)下载相应的版本,并创建账号(注意:登录docker账号才能下载镜像) + +(如果国外网站下载速度过慢,windows版本的docker安装文件群共享有) + + +### 1.1 执行以下命令获取镜像(2选1) + + +```shell + +docker pull quantaxis/quantaxis + + +``` + + +![执行时的命令行](http://pic.yutiansut.com/QQ%E6%88%AA%E5%9B%BE20171213102629.png) + + +### 1.2 运行镜像 + +``` +docker run -it -e GRANT_SUDO=yes --user root -p 8080:8080 quantaxis/quantaxis bash + +jupyter notebook --allow-root +(jupyter notebook 密码是 quantaxis) +``` + + + + +### 在浏览器中打开以下链接 +```angular2html + +http://localhost:8888 +``` + + +### 其他注意选项 + +1. docker 是可以通过ssh 连接的 ``` /etc/init.d/ssh start ``` +2. 多窗口 + +首先需要运行一个docker + +``` +A:\quantaxis [master ≡] +λ docker run -it -p 8080:8080 quantaxis/quantaxis bash +root@f22b5357dc6e:/# + +``` +然后在别的命令行执行 ``` docker ps``` 查询正在运行的docker的container_id +``` +A:\Users\yutia +λ docker ps + + +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +f22b5357dc6e quantaxis "bash" 21 seconds ago Up 20 seconds 0.0.0.0:8888->8888/tcp boring_panini + +``` +然后执行 ```docker exec -it [CONTAINERID] /bin/bash``` 进入 + +``` +A:\Users\yutia +λ docker exec -it f22b5357dc6e /bin/bash +root@f22b5357dc6e:/# + +``` + +