From 95d12646ea6c66738c9b0cf762c390f560f252d1 Mon Sep 17 00:00:00 2001 From: "vn.py" Date: Sat, 12 May 2018 17:34:32 +0800 Subject: [PATCH] =?UTF-8?q?[Add]=E6=B7=BB=E5=8A=A0web=20docker=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=90=AF=E5=8A=A8=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/vnc/README.md | 2 +- docker/web/Dockerfile | 4 ++-- docker/web/README.md | 11 +++++++++++ docker/web/build.sh | 4 ++++ docker/web/run.sh | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 docker/web/README.md create mode 100644 docker/web/build.sh create mode 100644 docker/web/run.sh diff --git a/docker/vnc/README.md b/docker/vnc/README.md index fee548f5..b2418d65 100644 --- a/docker/vnc/README.md +++ b/docker/vnc/README.md @@ -1,4 +1,4 @@ -# VNPY 的 Docker 镜像 +# VNC模式的Docker镜像 author: [@lamter](https://github.com/lamter) and [@crystalphi](https://github.com/crystalphi) diff --git a/docker/web/Dockerfile b/docker/web/Dockerfile index 07925b24..326bc66f 100644 --- a/docker/web/Dockerfile +++ b/docker/web/Dockerfile @@ -11,7 +11,7 @@ RUN rm /bin/sh && ln -s /bin/bash /bin/sh # Install software RUN apt-get update RUN apt-get install gcc g++ cmake libboost-all-dev -y -RUN apt-get install git bzip2 -y +RUN apt-get install git bzip2 vi nano -y RUN apt-get install libgl1-mesa-glx libglib2.0 libsm6 libxrender1 -y # Install Anaconda @@ -26,4 +26,4 @@ WORKDIR vnpy RUN bash install.sh # Set Entry Point -ENTRYPOINT python /vnpy/examples/WebTrader/run.py +WORKDIR vnpy/examples/WebTrader diff --git a/docker/web/README.md b/docker/web/README.md new file mode 100644 index 00000000..9300a24f --- /dev/null +++ b/docker/web/README.md @@ -0,0 +1,11 @@ +# WebTrader模式的Docker镜像 + +本镜像用于展示如何通过Docker来实现vn.py在生产环境中使用的一种快速部署方案,适合策略开发和实盘运维团队分离的专业机构。建议使用中根据自己的需求修改Dockerfile,在构建时加入自主开发的组件和策略。 + +使用步骤: +1. 在Ubuntu下运行命令安装Docker相关组件:sudo apt install docker docker.io +2. 运行build.sh构建镜像webtrader +3. 运行run.sh启动基于webtrader镜像的容器 +4. 进入后使用vi或者nano修改CTP_connect.json中的账户、密码、服务器地址信息 +5. 运行run.py启动无人值守模式的WebTrader(夜盘开盘前启动,下午收盘后自动关闭) +6. Docker中的WebTrader会连接外部环境的MongoDB来加载历史数据,所以请提前安装好 \ No newline at end of file diff --git a/docker/web/build.sh b/docker/web/build.sh new file mode 100644 index 00000000..23400eff --- /dev/null +++ b/docker/web/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# 构建镜像,不使用缓存 +docker build -t webtrader --no-cache . \ No newline at end of file diff --git a/docker/web/run.sh b/docker/web/run.sh new file mode 100644 index 00000000..9ecdb062 --- /dev/null +++ b/docker/web/run.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# 启动镜像,进入命令行 +docker run -it --net="host" webtrader