change mongodb port for docker build and fix celeryapp.py

This commit is contained in:
Jonathan Math 2020-10-25 12:36:58 +07:00
parent 55014fdc1b
commit 67e644aab0
5 changed files with 24 additions and 13 deletions

View file

@ -88,7 +88,7 @@ services:
container_name: db_mongo
image: mongo:3.2
ports:
- 27017:27017
- 29019:27017
command: mongod --smallfiles
volumes:
- ./docker/volumes/db_mongo:/data/db
@ -119,6 +119,7 @@ services:
container_name: node_favicons
environment:
- NODE_ENV=docker
- MONGO_PORT=29019
ports:
- 3030:3030
command: node favicons.js

View file

@ -1,7 +1,7 @@
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from django.apps import apps
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'newsblur_web.settings')
@ -11,7 +11,7 @@ app = Celery('newsblur')
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
app.config_from_object('django.conf:settings')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
app.autodiscover_tasks(lambda: [n.name for n in apps.get_app_configs()])

View file

@ -91,7 +91,7 @@ MONGO_DB = {
MONGO_ANALYTICS_DB = {
'name': 'nbanalytics',
'host': 'db_mongo',
'port': 27017,
'port': 29019,
}
MONGODB_SLAVE = {

View file

@ -53,7 +53,7 @@ DNSIMPLE_TOKEN = "YOUR_DNSIMPLE_TOKEN"
RECAPTCHA_SECRET_KEY = "YOUR_RECAPTCHA_KEY"
YOUTUBE_API_KEY = "YOUR_YOUTUBE_API_KEY"
IMAGES_SECRET_KEY = "YOUR_IMAGES_SECRET_KEY"
DOCKERBUILD = os.getenv("DOCKERBUILD")
# ===================
# = Global Settings =
# ===================
@ -508,13 +508,16 @@ CELERY_BEAT_SCHEDULE = {
# =========
# = Mongo =
# =========
if DOCKERBUILD:
MONGO_PORT = 29019
else:
MONGO_PORT = 27017
MONGO_DB = {
'host': 'db_mongo:27017',
'host': f'db_mongo:{MONGO_PORT}',
'name': 'newsblur',
}
MONGO_ANALYTICS_DB = {
'host': 'db_mongo_analytics:27017',
'host': f'db_mongo_analytics:{MONGO_PORT}',
'name': 'nbanalytics',
}
@ -576,7 +579,7 @@ S3_AVATARS_BUCKET_NAME = 'avatars.newsblur.com'
# ==================
# = Configurations =
# ==================
if os.getenv("DOCKERBUILD"):
if DOCKERBUILD:
from newsblur_web.docker_local_settings import *
else:
from newsblur_web.local_settings import *
@ -647,7 +650,7 @@ TEMPLATES = [
MONGO_DB_DEFAULTS = {
'name': 'newsblur',
'host': 'db_mongo:27017',
'host': f'db_mongo:{MONGO_PORT}',
'alias': 'default',
'connect': False,
}
@ -667,7 +670,7 @@ MONGODB = connect(MONGO_DB_NAME, **MONGO_DB)
MONGO_ANALYTICS_DB_DEFAULTS = {
'name': 'nbanalytics',
'host': 'db_mongo_analytics:27017',
'host': f'db_mongo_analytics:{MONGO_PORT}',
'alias': 'nbanalytics',
}
MONGO_ANALYTICS_DB = dict(MONGO_ANALYTICS_DB_DEFAULTS, **MONGO_ANALYTICS_DB)

View file

@ -1,6 +1,8 @@
import sys
from newsblur_web.settings import *
DOCKERBUILD = os.getenv("DOCKERBUILD")
if 'test' in sys.argv:
DATABASES['default']['ENGINE'] = 'django.db.backends.sqlite3'
DATABASES['default']['OPTIONS'] = {}
@ -14,9 +16,14 @@ if 'test' in sys.argv:
# 'TEST_NAME': ':memory:',
# },
# }
if DOCKERBUILD:
MONGO_PORT = 29019
else:
MONGO_PORT = 27017
MONGO_DB = {
'name': 'newsblur_test',
'host': '127.0.0.1:27017',
'host': '127.0.0.1:29019',
}
MONGO_DATABASE_NAME = 'test_newsblur'