mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
updated Dockerfile
This commit is contained in:
@@ -12,10 +12,11 @@ RUN cat /etc/resolv.conf
|
||||
|
||||
# install python
|
||||
RUN apt-get update
|
||||
RUN apt-get install python3 python3-pip net-tools iputils-ping
|
||||
RUN apt-get install -y python3 python3-pip net-tools iputils-ping
|
||||
|
||||
# soft link
|
||||
ln -s /usr/bin/pip3 /usr/local/bin/pip
|
||||
RUN ln -s /usr/bin/pip3 /usr/local/bin/pip
|
||||
RUN ln -s /usr/bin/python3 /usr/local/bin/python
|
||||
|
||||
# install required libraries
|
||||
RUN pip install -U setuptools
|
||||
@@ -25,6 +26,3 @@ RUN pip install -r /opt/crawlab/requirements.txt
|
||||
WORKDIR /opt/crawlab
|
||||
CMD python ./bin/run_worker.py
|
||||
CMD python app.py
|
||||
|
||||
# port
|
||||
EXPOSE 5000
|
||||
|
||||
29
app.py
29
app.py
@@ -1,13 +1,7 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
|
||||
from celery import Celery
|
||||
from flask import Flask
|
||||
from flask_cors import CORS
|
||||
from flask_restful import Api, Resource
|
||||
from flask_restful import Api
|
||||
|
||||
from config import BROKER_URL
|
||||
from routes.deploys import DeployApi
|
||||
from routes.files import FileApi
|
||||
from routes.nodes import NodeApi
|
||||
@@ -18,6 +12,7 @@ from routes.tasks import TaskApi
|
||||
# flask app instance
|
||||
app = Flask(__name__)
|
||||
app.config.from_object('config')
|
||||
|
||||
# init flask api instance
|
||||
api = Api(app)
|
||||
|
||||
@@ -25,7 +20,6 @@ api = Api(app)
|
||||
CORS(app, supports_credentials=True)
|
||||
|
||||
# reference api routes
|
||||
|
||||
api.add_resource(NodeApi,
|
||||
'/api/nodes',
|
||||
'/api/nodes/<string:id>',
|
||||
@@ -50,24 +44,5 @@ api.add_resource(StatsApi,
|
||||
'/api/stats',
|
||||
'/api/stats/<string:action>')
|
||||
|
||||
|
||||
def run_app():
|
||||
app.run()
|
||||
|
||||
|
||||
def run_flower():
|
||||
p = subprocess.Popen(['celery', 'flower', '-b', BROKER_URL], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
for line in iter(p.stdout.readline, 'b'):
|
||||
print(line.decode('utf-8'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# start flower app
|
||||
th_flower = threading.Thread(target=run_flower)
|
||||
th_flower.start()
|
||||
|
||||
# start flask app
|
||||
# th_app = threading.Thread(target=run_app)
|
||||
# th_app.start()
|
||||
app.run()
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ CELERY_MONGODB_BACKEND_SETTINGS = {
|
||||
'database': 'crawlab_test',
|
||||
'taskmeta_collection': 'tasks_celery',
|
||||
}
|
||||
|
||||
# flower variables
|
||||
FLOWER_API_ENDPOINT = 'http://localhost:5555/api'
|
||||
|
||||
# database variables
|
||||
@@ -22,3 +24,4 @@ MONGO_DB = 'crawlab_test'
|
||||
|
||||
# flask variables
|
||||
DEBUG = True
|
||||
SERVER_NAME = '0.0.0.0:5000'
|
||||
|
||||
Reference in New Issue
Block a user