FROM hub.c.163.com/public/ubuntu:16.04-tools #源鏡像 MAINTAINER adam.ding , dxf813@126.com COPY requirements.txt /tmp/ #拷貝python須要安裝文件 RUN apt-get update && apt-get -y install python3-pip libmysqlclient-dev python3-dev #python3-pip網易源沒有 RUN echo "deb http://mirrors.163.com/ubuntu/ precise main restricted universe multiverse" > /etc/apt/sources.list RUN apt-get update && apt-get install -y nginx redis-server git #下載一些基礎服務 RUN mkdir /root/.pip #home目錄 COPY pip.conf /root/.pip #拷貝更改的源配置文件 RUN pip3 install --upgrade pip RUN pip3 install matplotlib #此處不能放入requirement 必須分別安裝 RUN pip3 install numpy COPY nginx-start.conf /etc/supervisor/conf.d #拷貝nginx配置文件 RUN pip3 install pandas==0.17.1 RUN pip3 install zipline==1.0.2 COPY uwsgi.ini /usr/local/etc/#拷貝uwsgi配置文件 RUN pip3 install uwsgi COPY vue-dist /usr/local/src/dzh/#將打包好的vue項目文件夾拷貝到指定目錄 RUN pip3 install --requirement /tmp/requirements.txt RUN mkdir /usr/local/src/dzh WORKDIR /usr/local/src/dzh #切換到目錄 RUN git clone https://username:pad@xx.com/xx.git WORKDIR /usr/local/src/dzh/squant_tools RUN python3 setup.py build_ext --inplace#安裝系統 WORKDIR /etc/nginx/sites-enabled/ RUN mv default default.bb #將默認讀取配置文件更名 COPY nginx.conf . WORKDIR /usr/local/src/dzh/simple_login RUN python3 setup.py install COPY squant_tools.conf /etc/supervisor/conf.d CMD supervisord /etc/supervisor/supervisord.conf
3,部分其餘文件的配置vue
uwsgi.ini內容: [uwsgi] http-socket = :8000 plugin = python3 wsgi-file = /usr/local/src/dzh/squant_tools/quant/wsgi.py chdir= /usr/local/src/dzh/squant_tools module = quant.wsgi processes = 4 master=True vacuum=True 使用supervisor啓動如下進程 squant_tools.conf內容: [program:squant_tools] command = uwsgi /usr/local/etc/uwsgi.ini stopsignal=KILL autostart=true autorestart=true stdout_logfile=/usr/local/etc/supervisor_stdout.log stderr_logfile=/usr/local/etc/supervisor_stderr.log redirect_stderr=true nginx-start.conf內容: [program:nginx] command = service nginx start process_name=%(program_name)s numprocs=4 ; 啓動幾個進程 autostart=true ; 隨着supervisord的啓動而啓動 autorestart=true ; 自動重啓。。固然要選上了 startretries=10 ; 啓動失敗時的最多重試次數 stopsignal=KILL ; 用來殺死進程的信號 stopwaitsecs=10 ; 發送SIGKILL前的等待時間 redirect_stderr=true ; 重定向stderr到stdout requirements.txt內容: django mysqlclient psycopg2 cython pymssql celery django-cors-headers click cn-stock-holidays redis zipline_cn_databundle