Skip to content

Commit

Permalink
增加 推送镜像到 hub.docker.com
Browse files Browse the repository at this point in the history
  • Loading branch information
yhy committed Jan 11, 2018
1 parent 47e0c3c commit bafa967
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
27 changes: 25 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,37 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin \n\
30 17 1,10,20 * * /bin/run-parts /etc/cron.monthly \n" > /var/spool/cron/crontabs/root && \
chmod 600 /var/spool/cron/crontabs/root

#增加服务端口
EXPOSE 9999

#增加语言utf-8
ENV LANG=en_US.UTF-8
ENV LC_CTYPE=en_US.UTF-8
ENV LC_ALL=C

WORKDIR /data/stock
WORKDIR /data

RUN pip install grpcio tensorflow-serving-client statsmodels bokeh stockstats alphalens pyfolio supervisor && \
apt-get update && apt-get install -y mariadb-server quantlib-python net-tools

RUN sed -i 's/= \/var\/lib\/mysql/= \/data\/mariadb/g' /etc/mysql/mariadb.conf.d/50-server.cnf

RUN pip install supervisor
#经常修改放到最后:
ADD jobs /data/stock/jobs
ADD libs /data/stock/libs
ADD tf /data/stock/tf
ADD web /data/stock/web
ADD supervisor /etc/supervisor

ADD jobs/cron.minutely /etc/cron.minutely
ADD jobs/cron.hourly /etc/cron.hourly
ADD jobs/cron.daily /etc/cron.daily
ADD jobs/cron.monthly /etc/cron.monthly

RUN mkdir -p /data/logs && ls /data/stock/ && chmod 755 /data/stock/jobs/run_* && \
chmod 755 /etc/cron.minutely/* && chmod 755 /etc/cron.hourly/* && \
chmod 755 /etc/cron.daily/* && chmod 755 /etc/cron.monthly/* && \
ln -s /data/stock/libs/ /usr/lib/python3.5/libs && \
ln -s /data/stock/web/ /usr/lib/python3.5/web

ENTRYPOINT ["supervisord","-n","-c","/etc/supervisor/supervisord.conf"]
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
DOCKER_TAG=pythonstock/pythonstock:latest

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

DATE=`date +%Y-%m-%d:%H:%M:%S`
echo $DATE

if [ ! -d "/data/mariadb" ]; then
mkdir -p /data/mariadb
/usr/bin/mysql_install_db
fi


/usr/bin/mysqld_safe >> /data/logs/start_mariadb.log
33 changes: 6 additions & 27 deletions startStock.sh
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
#!/bin/sh


HAS_TF=`docker images tensorflow/tensorflow | wc -l `
if [ $HAS_TF -lt 2 ];then
docker pull tensorflow/tensorflow:latest-devel
fi

HAS_TF_BASE=`docker images github.com/pythonstock/stock/tensorflow-py3 | wc -l `
if [ $HAS_TF -lt 2 ];then
sh buildBase.sh
fi

HAS_TF_BASE=`docker images github.com/pythonstock/stock/tensorflow-py3-stock | wc -l `
if [ $HAS_TF -lt 2 ];then
sh buildStock.sh
fi

DB_IS_RUN=`docker ps --filter "name=mariadb" --filter "status=running" | wc -l `
if [ $DB_IS_RUN -lt 2 ]; then
sh startMysql.sh
fi

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

sleep 1

echo "starting stock ..."
echo "starting pythonstock ..."
# /data/stock 是代码目录 -v /data/stock:/data/stock 是开发模式。
docker run -itd --link=mariadb --name stock \
docker run -itd --name pythonstock \
-p 8888:8888 \
-p 6006:6006 \
-p 9999:9999 \
-p 8500:8500 \
github.com/pythonstock/stock/tensorflow-py3-stock:latest
pythonstock/pythonstock:latest
9 changes: 9 additions & 0 deletions supervisor/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ startsecs=5
priority=1
stopasgroup=true
killasgroup=true

[program:mariadb]
command=/data/stock/jobs/start_mariadb.sh
autostart=true
autorestart=true
startsecs=20
priority=1
stopasgroup=true
killasgroup=true

0 comments on commit bafa967

Please sign in to comment.