diff --git a/docker-compose.yml b/docker-compose.yml index cbee44f..b04b5e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,4 +66,3 @@ services: network_mode: host build: context: ./emitter - entrypoint: /emitter/camtiler.py diff --git a/emitter/Dockerfile b/emitter/Dockerfile index 5fd09d2..80d8f4a 100644 --- a/emitter/Dockerfile +++ b/emitter/Dockerfile @@ -1,6 +1,7 @@ FROM python -WORKDIR /emitter +RUN pip install pymongo + COPY ./emitter.py ./ -ENTRYPOINT emitter.py +CMD ["python", "./emitter.py"] LABEL name="emitter" diff --git a/emitter/emitter.py b/emitter/emitter.py index f6de0e1..44fd63b 100644 --- a/emitter/emitter.py +++ b/emitter/emitter.py @@ -2,12 +2,11 @@ from pymongo import MongoClient from bson.objectid import ObjectId from time import sleep -MONGO_URI="mongodb://127.0.0.1:27017" +MONGO_URI="mongodb://127.0.0.1:27017/default" -client = MongoClient(MONGO_URI) -db = client['default'] -col = db['eventlog'] +db = MongoClient(MONGO_URI).get_default_database() while True: - col.insertOne({"foo": "bar"}) + db.eventlog.insert_one({ "timestamp": "...", "event": "motion-detected", "started": "...", "finished": "...", "component": "motion-detect", "camera": "Server room", "action": "event", + }) sleep(1) diff --git a/mongo-init.sh b/mongo-init.sh new file mode 100644 index 0000000..5dacf7a --- /dev/null +++ b/mongo-init.sh @@ -0,0 +1,11 @@ +#!/bin/bash +mongo <