From 5d43b8a72f096616b14b62c8cbeff3ee75c610ea Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Wed, 12 Jun 2019 21:23:22 +0800 Subject: [PATCH] add auth to mongodb connection --- Dockerfile | 8 ++++---- crawlab/config/config.py | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6fdb5142..5622fb0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,13 +30,13 @@ ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH # install frontend -RUN npm install -g yarn --registry=https://registry.npm.taobao.org \ +RUN npm install -g yarn \ && cd /opt/crawlab/frontend \ - && yarn install --registry=https://registry.npm.taobao.org + && yarn install # install backend -RUN pip install -U setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple \ - && pip install -r /opt/crawlab/crawlab/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple +RUN pip install -U setuptools \ + && pip install -r /opt/crawlab/crawlab/requirements.txt # start backend EXPOSE 8080 diff --git a/crawlab/config/config.py b/crawlab/config/config.py index 8702e00f..14380b73 100644 --- a/crawlab/config/config.py +++ b/crawlab/config/config.py @@ -25,7 +25,10 @@ MONGO_DB = 'crawlab_test' BROKER_URL = 'redis://127.0.0.1:6379/0' # Celery后台URL -CELERY_RESULT_BACKEND = 'mongodb://127.0.0.1:27017/' +if MONGO_USERNAME is not None: + CELERY_RESULT_BACKEND = f'mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@{MONGO_HOST}:{MONGO_PORT}/' +else: + CELERY_RESULT_BACKEND = f'mongodb://{MONGO_HOST}:{MONGO_PORT}/' # Celery MongoDB设置 CELERY_MONGODB_BACKEND_SETTINGS = { @@ -42,7 +45,6 @@ CELERY_ENABLE_UTC = True # flower variables FLOWER_API_ENDPOINT = 'http://localhost:5555/api' - # Flask 变量 DEBUG = False FLASK_HOST = '0.0.0.0'