Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My branch #111

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# 基础镜像,按照季度,月度更新。不影响应用镜像的构建。

FROM pythonstock/pythonstock:base-2021-09
FROM pythonstock/pythonstock:2022-01

WORKDIR /data

Expand Down
5 changes: 1 addition & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

DOCKER_TAG=pythonstock/pythonstock:latest

sudo rm -rf data
sudo rm -f jobs/nohup.out

echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
docker build -f Dockerfile -t ${DOCKER_TAG} .
sudo docker build -f Dockerfile -t ${DOCKER_TAG} .
echo "#################################################################"
echo " docker push ${DOCKER_TAG} "

mkdir data

49 changes: 29 additions & 20 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#使用 python:3.7-slim 做基础镜像减少大小。其中tensorflow再用另外的镜像跑数据。
# akshare 推荐python3.8.5+, 使用 python:3.8-slim 做基础镜像。其中tensorflow再用另外的镜像跑数据。

# 之前使用的是python:3.6-slim
# 可以更新 3.7-slim-stretch slim-stretch
# 之前使用的是3.7-slim-stretch
# 现在更新 3.8-slim-buster slim-buster

# https://hub.docker.com/_/python?tab=tags&page=1&name=3.7-slim-stretch
# https://hub.docker.com/_/python?tab=tags&page=1&name=3.8-slim-buster
# 用这个做为基础镜像,防止每次都进行构建。

FROM docker.io/python:3.7-slim-stretch
FROM docker.io/python:3.8-slim-buster

# https://opsx.alibaba.com/mirror
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
RUN echo "deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib\n\
deb http://mirrors.aliyun.com/debian-security stretch/updates main\n\
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main\n\
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib\n\
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib" > /etc/apt/sources.list && \
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb-src http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" > /etc/apt/sources.list && \
echo "[global]\n\
trusted-host=mirrors.aliyun.com\n\
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf && \
Expand All @@ -30,6 +30,9 @@ ENV LC_CTYPE=zh_CN.UTF-8
ENV LC_ALL=C
ENV PYTHONPATH=/data/stock

# 解决warning "debconf: unable to initialize frontend: Dialog"
ENV DEBIAN_FRONTEND noninteractive

# 增加 TensorFlow 的支持,使用最新的2.0 编写代码。目前还是使用 1.x 吧,还没有学明白。
# RUN pip3 install tensorflow==2.0.0-rc1 keras
# RUN pip3 install tensorflow keras sklearn
Expand All @@ -44,15 +47,21 @@ RUN mkdir -p /etc/vim/ && \
# 安装 nodejs 库
# apt-get autoremove -y 删除没有用的依赖lib。减少镜像大小。1MB 也要节省。
# apt-get --purge remove 软件包名称 , 删除已安装包(不保留配置文件)。
RUN apt-get update && apt-get install -y net-tools procps gcc make python3-dev default-libmysqlclient-dev libxml2-dev cron && \
pip3 install mysqlclient sqlalchemy && \
pip3 install supervisor && \
RUN apt-get update

# 解决warning "debconf: delaying package configuration, since apt-utils is not installed"
RUN apt-get install --assume-yes apt-utils

RUN apt-get install -y net-tools procps gcc make default-libmysqlclient-dev cron && \
pip3 install mysqlclient && \
apt-get --purge remove -y gcc make default-libmysqlclient-dev && \
pip3 install supervisor sqlalchemy && \
pip3 install numpy pandas && \
pip3 install akshare --upgrade && \
apt-get install -y nodejs && \
pip3 install tornado torndb && \
pip3 install bokeh stockstats sklearn && \
apt-get --purge remove -y gcc make python3-dev default-libmysqlclient-dev libxml2-dev && \
pip3 install jupyter && \
rm -rf /root/.cache/* && apt-get clean && apt-get autoremove -y

# /usr/local/lib/python3.7/site-packages/pandas/
Expand All @@ -69,11 +78,11 @@ RUN apt-get update && apt-get install -y net-tools procps gcc make python3-dev d

RUN echo `date +%Y-%m-%d:%H:%M:%S` >> /etc/docker.build && \
sed -i -e 's/executemany(statement/executemany(statement.replace\("INSERT INTO","INSERT IGNORE INTO")/g' \
/usr/local/lib/python3.7/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
/usr/local/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mysqldb.py && \
rm -f /etc/cron.daily/apt-compat /etc/cron.daily/dpkg /etc/cron.daily/passwd && \
sed -i -e 's/itertools\.izip/zip/g' \
/usr/local/lib/python3.7/site-packages/torndb.py && \
/usr/local/lib/python3.8/site-packages/torndb.py && \
sed -i -e 's/\+ CONVERSIONS\[field_type\]/\+ \[CONVERSIONS\[field_type\],bytes\]/g' \
/usr/local/lib/python3.7/site-packages/torndb.py
/usr/local/lib/python3.8/site-packages/torndb.py


55 changes: 55 additions & 0 deletions docker/Dockerfile_vnpy
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 使用 python:3.7-slim-buster 做基础镜像。
# https://hub.docker.com/_/python?tab=tags&page=1&name=3.7-slim-buster

FROM docker.io/python:3.7-slim-buster

# https://opsx.alibaba.com/mirror
# 使用阿里云镜像地址。修改debian apt 更新地址,pip 地址,设置时区。
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb-src http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" > /etc/apt/sources.list && \
apt-get update && \
echo "[global]\n\
trusted-host=mirrors.aliyun.com\n\
index-url=https://mirrors.aliyun.com/pypi/simple/" > /etc/pip.conf && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone


#增加语言GB18030
ENV LANG=zh_CN.GB18030
ENV LC_CTYPE=zh_CN.GB18030
ENV LC_ALL=C
ENV PYTHONPATH=/data/vnpy

# 解决warning "debconf: unable to initialize frontend: Dialog"
ENV DEBIAN_FRONTEND noninteractive

# 解决warning "debconf: delaying package configuration, since apt-utils is not installed"
RUN apt-get install --assume-yes apt-utils && pip3 install pip --upgrade

RUN apt-get install -y gcc g++ make wget git vim && \
apt-get install -y libgl1-mesa-glx libglib2.0-0 libfontconfig1 libxkbcommon-x11-0 && \
apt-get install -y libdbus-1-3 xfonts-intl-chinese xfonts-wqy locales && \
echo "zh_CN.GB18030 GB18030" >> /etc/locale.gen && locale-gen && \
pip3 install numpy==1.18.2 && \
cd /tmp && wget https://pip.vnpy.com/colletion/ta-lib-0.4.0-src.tar.gz && \
tar xvfz ta-lib-0.4.0-src.tar.gz && \
cd ta-lib && ./configure && make && make install && pip3 install ta-lib==0.4.17 && \
echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc && \
cd /tmp && git clone https://github.91chi.fun//https://github.com/vnpy/vnpy.git && \
cd /tmp/vnpy && pip3 install -r requirements.txt && pip3 install . && \
cd /tmp && rm -rf *

# 设置 vim 的语言配置
RUN mkdir -p /etc/vim/ && \
echo "set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936" >> /etc/vim/vimrc && \
echo "set termencoding=utf-8" >> /etc/vim/vimrc && \
echo "set encoding=utf-8" >> /etc/vim/vimrc

WORKDIR /data
2 changes: 1 addition & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

NOW_MONTH=$(date "+%Y-%m")

DOCKER_TAG=pythonstock/pythonstock:base-${NOW_MONTH}
DOCKER_TAG=pythonstock/pythonstock:${NOW_MONTH}

echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
docker build -f Dockerfile -t ${DOCKER_TAG} .
Expand Down
14 changes: 14 additions & 0 deletions docker/build_vnpy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh


NOW_MONTH=$(date "+%Y-%m")

#DOCKER_TAG=gao9/vnpy:${NOW_MONTH}
DOCKER_TAG=gao9/vnpy:latest

echo " docker build -f Dockerfile -t ${DOCKER_TAG} ."
docker build -f Dockerfile_vnpy -t ${DOCKER_TAG} .
echo "#################################################################"
echo " docker push ${DOCKER_TAG} "


28 changes: 28 additions & 0 deletions docker/startVnpy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

PWD=`pwd`

#检查vnpy启动
VNPY_IS_RUN=`docker ps --filter "name=vnpy" --filter "status=running" | wc -l `
if [ $VNPY_IS_RUN -ge 2 ]; then
echo "stop & rm vnpy ..."
docker stop vnpy && docker rm vnpy
fi

sleep 1

echo "starting vnpy ..."
#映射本地代码。

echo "############# run dev ############# "
docker run -itd --name vnpy \
--net=host --env="DISPLAY" \
-e LANG=zh_CN.GB18030 -e LC_CTYPE=zh_CN.GB18030 -e PYTHONIOENCODING=utf-8 \
-p 8888:8888 -p 8000:8000 --restart=always \
-v $(realpath ~/.Xauthority):/root/.Xauthority \
-v ${PWD}/../../../vnpy:/data/vnpy \
-v ${PWD}/../data/logs:/data/logs \
gao9/vnpy:latest
exit 1;


Loading