104 lines
5.2 KiB
Plaintext
104 lines
5.2 KiB
Plaintext
#FROM docker.io/tensorflow/tensorflow:latest-py3
|
|
FROM docker.io/tensorflow/tensorflow:latest-devel-py3
|
|
|
|
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n\
|
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n\
|
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n\
|
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n\
|
|
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse \n\
|
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse \n\
|
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse \n\
|
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse \n\
|
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse \n\
|
|
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse " > /etc/apt/sources.list
|
|
|
|
RUN echo "[global]\n\
|
|
trusted-host=mirrors.aliyun.com\n\
|
|
index-url=http://mirrors.aliyun.com/pypi/simple" > /etc/pip.conf
|
|
|
|
#timezone
|
|
RUN apt-get update && apt-get install -y tzdata && \
|
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
|
|
echo "Asia/Shanghai" > /etc/timezone && \
|
|
apt-get clean
|
|
|
|
#install other lib
|
|
RUN apt-get update && apt-get install -y python3-dev libmysqlclient-dev libhdf5-dev && \
|
|
pip3 install mysqlclient && \
|
|
pip3 install sqlalchemy && \
|
|
pip3 install requests && \
|
|
apt-get install -y libxml2-dev && pip3 install lxml bs4 && \
|
|
pip3 install tushare && \
|
|
apt-get clean && apt-get remove -y python3-dev libmysqlclient-dev && \
|
|
pip3 install unittest2 && \
|
|
pip3 install torndb && \
|
|
pip3 install bcrypt && \
|
|
pip3 install --upgrade tables
|
|
|
|
#1.解决 pandas 数据插入问题。直接修改数据库驱动 sqlalchemy 修改:statement.replace("INSERT INTO","INSERT IGNORE INTO")
|
|
# /usr/local/lib/python3.5/dist-packages/sqlalchemy/dialects/mysql/mysqldb.py
|
|
# 增加了一个 IGNORE 参数。
|
|
#2.解决torndb在python3下面的问题:
|
|
#http://blog.csdn.net/littlethunder/article/details/8917378
|
|
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.5/dist-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.5/dist-packages/torndb.py
|
|
|
|
# tensorflow-serving-api
|
|
# https://github.com/tensorflow/tensorflow/issues/12159
|
|
# serving-api not support !!!
|
|
#增加 statsmodels lib。apscheduler
|
|
RUN pip3 install grpcio tensorflow-serving-client statsmodels bokeh stockstats alphalens pyfolio
|
|
|
|
#需要编译数个小时,慢慢等待。
|
|
RUN cd /root && curl -o QuantLib-1.11.tar.gz https://codeload.github.com/lballabio/QuantLib/tar.gz/QuantLib-v1.11 && \
|
|
curl -o QuantLib-SWIG-1.11.tar.gz https://codeload.github.com/lballabio/QuantLib-SWIG/tar.gz/QuantLib-SWIG-v1.11 && \
|
|
apt-get update && apt-get install -y python-dev swig automake autoconf libtool libboost-all-dev && \
|
|
tar -zxvf QuantLib-1.11.tar.gz && tar -zxvf QuantLib-SWIG-1.11.tar.gz && \
|
|
cd QuantLib-QuantLib-v1.11 && ./autogen.sh && ./configure && make && make install && ldconfig
|
|
|
|
RUN cd /root/QuantLib-SWIG-QuantLib-SWIG-v1.11 && ./autogen.sh && ./configure PYTHON=/usr/bin/python3 && \
|
|
make -C Python && make -C Python install && apt-get remove -y python-dev swig automake autoconf libtool && \
|
|
rm -rf /root/QuantLib-QuantLib-v1.11 && rm -rf /root/QuantLib-SWIG-QuantLib-SWIG-v1.11
|
|
|
|
#add cron sesrvice.
|
|
#每分钟,每小时1分钟,每天1点1分,每月1号执行
|
|
RUN apt-get update && apt-get install -y cron vim && \
|
|
mkdir -p /etc/cron.minutely && \
|
|
echo "SHELL=/bin/sh \n\
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
|
|
# min hour day month weekday command \n\
|
|
*/1 * * * * /bin/run-parts /etc/cron.minutely \n\
|
|
10 * * * * /bin/run-parts /etc/cron.hourly \n\
|
|
30 18 * * * /bin/run-parts /etc/cron.daily \n\
|
|
30 15 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
|
|
chmod 600 /var/spool/cron/crontabs/root
|
|
|
|
#add cron
|
|
RUN echo "#!/usr/bin/env bash \n\
|
|
/usr/sbin/cron \n\
|
|
nohup /bin/sh /data/stock/jobs/run_init.sh 2>&1 & \n\
|
|
sleep 1 \n\
|
|
nohup /usr/local/bin/tensorboard --logdir=/data/logs/tensorflow 2>&1 & \n\
|
|
sleep 1 \n\
|
|
nohup /usr/bin/python3 /data/stock/jobs/aps_job.py >> /data/logs/aps_job.log 2>&1 & \n\
|
|
sleep 1 \n\
|
|
nohup /usr/bin/python3 /data/stock/web/main.py >> /data/logs/tornado.log 2>&1 & \n\
|
|
sleep 1 \n\
|
|
if [ ! -d "/notebooks" ]; then \n\
|
|
mkdir -p /notebooks \n\
|
|
fi \n\
|
|
jupyter notebook --allow-root --NotebookApp.token='' --notebook-dir=/notebooks > /notebooks/jupyter-notebook.log " > /run_jupyter.sh
|
|
|
|
|
|
#增加语言utf-8
|
|
ENV LC_CTYPE=en_US.UTF-8
|
|
ENV LC_ALL=en_US.UTF-8
|
|
ENV LANG=en_US.UTF-8
|
|
|
|
WORKDIR /data/stock
|
|
|
|
ENTRYPOINT ["/run_jupyter.sh"] |