mrlt8 / docker-wyze-bridge

WebRTC/RTSP/RTMP/LL-HLS bridge for Wyze cams in a docker container
GNU Affero General Public License v3.0
2.45k stars 151 forks source link

Environment Secrets Not Working #1264

Closed crazytimmy closed 1 week ago

crazytimmy commented 1 week ago

Previously I've been entering my Wyze credentials & API key manually on login after starting container.

I've just tried to use docker secrets for WYZE_EMAIL, WYZE_PASSWORD, API_ID, API_KEY but they don't seem to be working.

Here is the log after starting container:

🚀 DOCKER-WYZE-BRIDGE v2.9.7 X86_64
[WyzeBridge] [WARN] Credentials are NOT set
[WyzeBridge] 🔍 Could not find local cache for 'auth'
[WyzeBridge] ☁️ Fetching 'auth' from the Wyze API...
[WyzeBridge] Credentials required to complete login!
 * Serving Flask app 'frontend'
 * Debug mode: off
[WyzeBridge] Please visit the WebUI to enter your credentials.
[WyzeBridge] WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on all addresses (0.0.0.0)
 * Running on http://127.0.0.1:5000
 * Running on http://172.28.0.2:5000
[WyzeBridge] Press CTRL+C to quit

Here is the relevant part of my docker-compose.yml:

services:
  wyze-bridge:
    image: mrlt8/wyze-bridge:latest
    container_name: wyze-bridge
    environment:
      - WYZE_EMAIL_FILE=/run/secrets/wyze_email
      - WYZE_PASSWORD_FILE=/run/secrets/wyze_password
      - API_ID_FILE=/run/secrets/wyze_api_id
      - API_KEY_FILE=/run/secrets/wyze_api_key
      - ROTATE_DOOR=True
      - WB_AUTH=False
      - NET_MODE=LAN
      - SUBSTREAM=True
...
    secrets:
      - wyze_email
      - wyze_password
      - wyze_api_id
      - wyze_api_key
    restart: unless-stopped
...
secrets:
  wyze_email:
    file: /home/<USER>/secrets/wyze_email.txt
  wyze_password:
    file: /home/<USER>/secrets/wyze_password.txt
  wyze_api_id:
    file: /home/<USER>/secrets/wyze_api_id.txt
  wyze_api_key:
    file: /home/<USER>/secrets/wyze_api_key.txt

Host secrets directory:

$ ls -l /home/<USER>/
total 12
...
drwxr-xr-x 2 jeff jeff 4096 Jun 16 12:41 secrets

Container secrets directory:

$ docker exec -it wyze-bridge bash
root@0c72dbf41822:/app# ls -l /run/secrets/
total 16
-rw-r--r-- 1 1000 1000 37 Feb 21 17:16 wyze_api_id
-rw-r--r-- 1 1000 1000 61 Feb 21 17:16 wyze_api_key
-rw-r--r-- 1 1000 1000 20 Jun 16 17:41 wyze_email
-rw-r--r-- 1 1000 1000 31 Jun 16 17:41 wyze_password

Contents of each secret print out correctly.

Environment (if applicable)

Any thoughts on why this doesn't seem to work?

crazytimmy commented 1 week ago

I just tried passing the environment variables directly in the docker-compose.yml file and that seems to have worked as expected.

Adding links that I've read regarding secrets: https://github.com/mrlt8/docker-wyze-bridge?tab=readme-ov-file#whats-changed-in-v296 https://github.com/mrlt8/docker-wyze-bridge/issues/1244#issue-2332599607

mrlt8 commented 1 week ago

Your names are wrong. Try something like:

services:
  wyze-bridge:
    image: mrlt8/wyze-bridge:latest
    container_name: wyze-bridge
    environment:
      - ROTATE_DOOR=True
      - WB_AUTH=False
      - NET_MODE=LAN
      - SUBSTREAM=True
    secrets:
      - WYZE_EMAIL
      - WYZE_PASSWORD
      - API_ID
      - API_KEY
    restart: unless-stopped
secrets:
  WYZE_EMAIL:
    file: /home/<USER>/secrets/wyze_email.txt
  WYZE_PASSWORD:
    file: /home/<USER>/secrets/wyze_password.txt
  API_ID:
    file: /home/<USER>/secrets/wyze_api_id.txt
  API_KEY:
    file: /home/<USER>/secrets/wyze_api_key.txt
crazytimmy commented 1 week ago

Thanks for the reply, that was my issue.