Skip to content
This repository has been archived by the owner on Feb 4, 2020. It is now read-only.

Commit

Permalink
Always rely on MONGO_URL when connecting to mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
karolgil committed Oct 22, 2018
1 parent 60d8ae8 commit ff55358
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ RUN pipenv install
ENV CREDS_PATH=$APP/configs/creds.yml
ENV CONFIG_PATH=$APP/config.yml

ENV MONGO_URL="localhost:27017"
RUN pipenv run py.test --cov-report=html --cov=app --junit-xml=report.xml .
4 changes: 1 addition & 3 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

def main() -> None:
app_config = TriggearConfig()

motor_mongo = motor.motor_asyncio.AsyncIOMotorClient() if not os.environ.get('COMPOSE') == 'true' \
else motor.motor_asyncio.AsyncIOMotorClient(os.environ.get('MONGO_URL'))
motor_mongo = motor.motor_asyncio.AsyncIOMotorClient(os.environ.get('MONGO_URL'))

gh_client = GithubClient(app_config.github_token)
mongo_client = MongoClient(mongo=motor_mongo)
Expand Down
12 changes: 7 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ services:
build: .
command: pipenv run python app/main.py
depends_on:
- mongodb
- mongodb
ports:
- 8080:8080
volumes:
- ./configs/creds.yml:/usr/src/creds/creds.yml
- ./configs/creds.yml:/usr/src/triggear/configs/creds.yml
links:
- 'mongodb:mongodb'
environment:
- COMPOSE=true
- PYTHONPATH=/usr/src/triggear
- MONGO_URL=mongodb:27017
- PYTHONPATH=/usr/src/triggear
mongodb:
image: "bitnami/mongodb:latest"
ports:
- 27017:27017
networks:
- default
- default
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def test__main_app_flow(self):
.TriggearConfig()\
.thenReturn(triggear_config)
expect(motor.motor_asyncio)\
.AsyncIOMotorClient()\
.AsyncIOMotorClient('localhost:27017')\
.thenReturn(motor_client)
expect(app.clients.github_client)\
.GithubClient('gh_token')\
Expand Down

0 comments on commit ff55358

Please sign in to comment.