From e408ff47d5704c2ef19a234bec67adadc776d228 Mon Sep 17 00:00:00 2001 From: slashtechno <77907286+slashtechno@users.noreply.github.com> Date: Sat, 17 Dec 2022 21:55:17 -0600 Subject: [PATCH] Worked on Docker Compose --- .gitignore | 3 ++- docker-compose.yml | 54 ++++++++++++++++++++++++++++++++++++++++++++++ main.py | 6 ++++-- 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 36836c1..658b8fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # person.jpg # config.json -config/ \ No newline at end of file +config/ +.env \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..cdd743a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +version: '2.4' +networks: + all: +services: + bridge: + container_name: bridge-wyze + restart: unless-stopped + image: mrlt8/wyze-bridge:latest + # ports: + # - 1935:1935 # RTMP + # - 8554:8554 # RTSP + # - 8888:8888 # HLS + # - 5000:5000 # WEB-UI + environment: + - WYZE_EMAIL=${WYZE_EMAIL} # Replace with wyze email + - WYZE_PASSWORD=${WYZE_PASSWORD} # Replace with wyze password + networks: + all: + aliases: + - bridge + ntfy: + image: binwiederhier/ntfy + container_name: ntfy-wyze + command: + - serve + environment: + - TZ=UTC # optional: set desired timezone + # volumes: + # - /var/cache/ntfy:/var/cache/ntfy + # - /etc/ntfy:/etc/ntfy + ports: + - 9216:80 + restart: unless-stopped + networks: + all: + facial_recognition: + container_name: face-recognition-wyze + restart: unless-stopped + image: ghcr.io/slashtechno/wyze_face_recognition:latest + volumes: + # ./config is mounted as /app/config + - ./config:/app/config + networks: + all: + environment: + - RUN_BY_COMPOSE=true + depends_on: + - bridge + # Use wait-for-it to wait for the bridge at port 8554 to be ready and then run /app/main.py + command: /bin/sh -c "wait-for-it.sh bridge:8554 --timeout=0 --strict -- /app/main.py" + + +# How can this be run and a .env file passed? +# docker-compose up -d --env-file .env diff --git a/main.py b/main.py index d0c6d49..ee40485 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,7 @@ DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" # RUN_SCALE = 0.25 # VIEW_SCALE = 0.75 DISPLAY = False +RUN_BY_COMPOSE = os.getenv("RUN_BY_COMPOSE") def find_face_from_name(name): @@ -40,7 +41,8 @@ process_this_frame = True # Load the config file, if it does not exist or is blank, create it config = { - "URL": "rtsp://localhost:8554/example", + # If RUN_BY_COMPOSE is true, set url to rtsp://wyze-bridge:8554/wyze_cam_name, otherwise set it to "rtsp://localhost:8554/wyze_cam_name" + "URL": "rtsp://localhost:8554/wyze_cam_name" if not RUN_BY_COMPOSE else "rtsp://wyze-bridge:8554/wyze_cam_name", "run_scale": "0.25", "view_scale": "0.75", "faces": { @@ -175,7 +177,7 @@ while True: ) # Display the resulting image if DISPLAY is set to true - if DISPLAY: + if config["display"]: cv2.imshow("Scaled View", view_frame) # Hit 'q' on the keyboard to quit!