瀏覽代碼

Add docker compose and requirements for API

oscarleiva 7 年之前
父節點
當前提交
cabacff935

+ 17 - 0
flask_api/docker-compose.yml

@@ -0,0 +1,17 @@
+version: '2'
+
+services:
+
+  web:
+    build:
+      context: ./web/
+    ports:
+      - "8000:8000"
+
+  nginx:
+    restart: always
+    build: ./nginx/
+    ports:
+      - "80:80"
+    links:
+      - web

+ 3 - 0
flask_api/nginx/Dockerfile

@@ -0,0 +1,3 @@
+FROM tutum/nginx
+RUN rm /etc/nginx/sites-enabled/default
+ADD sites-enabled/ /etc/nginx/sites-enabled

+ 14 - 0
flask_api/nginx/sites-enabled/app

@@ -0,0 +1,14 @@
+server {
+
+    listen 80;
+    server_name 0.0.0.0;
+    charset utf-8;
+
+    location / {
+        proxy_pass http://web:8000;
+        proxy_set_header Host $host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
+}

+ 8 - 0
flask_api/web/Dockerfile

@@ -0,0 +1,8 @@
+FROM continuumio/miniconda
+LABEL maintainer="Peng Xiao<xiaoquwl@gmail.com>"
+
+COPY . /
+
+RUN pip install -r requirements.txt && pip install gunicorn
+
+ENTRYPOINT ["/runserver.sh"]

+ 0 - 0
flask_api/__init__.py → flask_api/web/app/__init__.py


+ 0 - 0
flask_api/models/lbrprice_model_svr.pkl → flask_api/web/app/models/lbrprice_model_svr.pkl


+ 0 - 0
flask_api/server.py → flask_api/web/app/server.py


+ 0 - 0
flask_api/utils.py → flask_api/web/app/utils.py


+ 3 - 0
flask_api/web/requirements.txt

@@ -0,0 +1,3 @@
+numpy==1.15.4
+Flask==1.0.2
+pandas==0.23.4

+ 3 - 0
flask_api/web/runserver.sh

@@ -0,0 +1,3 @@
+#!/bin/bash
+
+gunicorn --log-level info --log-file=/gunicorn.log --workers 4 --name app -b 0.0.0.0:8000 --reload app.server:app