Open Megaptera666 opened 10 months ago
@Megaptera666 Is there a reason you manually installed yarn and ran the start command? These steps are already included in the Dockerfile and start_docker.sh script which run when the container is built.
While troubleshooting, I uncovered that the start_docker.sh
script was unexpectedly obstructing the execution of main.py
. The issue became apparent when I delved into the container with docker exec -it <container_id>
and initiated yarn --cwd webapp start
. This command continued to execute without termination, concluding with the message No issues found.
Crucially, this command facilitates content delivery over port 80
. Nonetheless, its execution sequence, utilizing &&, was inadvertently preventing the launch of python3 main.py
. The latter is crucial as it delivers content on ports 8000
and 8001
, both of which are vital dependencies for the webapp. With the issue resolved, the system is now operational, and I share this resolution in hopes that it may assist others facing similar challenges.
I can happily say - no more errors for me!
I made the following changes to start_docker.sh
:
#!/bin/bash
# Start the Node.js app in the background
yarn --cwd webapp start &
# Start the app
python3 main.py
To apply these changes, the Docker container needs to be rebuilt:
docker-compose stop baby-sleep-coach
docker-compose rm -f baby-sleep-coach
docker-compose up --build -d baby-sleep-coach
If you are running out of space like me you might need to prune (thread lightly)
docker system prune -a -f
I am encountering an issue where nothing seems to be listening on ports 8000 or 8001 inside the Docker container. This issue persists despite several attempts at troubleshooting, which I have documented below.
main.py
: Changed the line 71 from if focusRegionArr[0] is '':
to if focusRegionArr[0] == '':
.package.json
of WebApp:
&
from the script
section. Previously, it was react-scripts start&
.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
}
devDependencies
:
"devDependencies": {
"@types/d3": "^7.4.0",
"typescript": "^5.1.6",
"@babel/plugin-proposal-private-property-in-object": "^7.16.0"
}
.env File:
CAM_URL=rtsp://rtsproot:nonya@192.168.100.134:554/stream1
APP_DIR=/usr/app/babysleepcoach
DEBUG=False
OWL=False
VIDEO_PATH=/usr/app/babysleepcoach/video
REACT_APP_BACKEND_IP=192.168.100.136:8001
REACT_APP_RESOURCE_SERVER_IP=192.168.100.136:8000
PORT=80
Dockerfile:
FROM node:slim
WORKDIR /usr/app/babysleepcoach
EXPOSE 80
# Copy all files into the container
COPY . .
# Install required packages
ENV PIP_BREAK_SYSTEM_PACKAGES 1
RUN apt-get update && apt-get install python3-pip libgl1 libglib2.0-0 -y
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN cd webapp && yarn install && cd ..
WORKDIR /usr/app/babysleepcoach
ENTRYPOINT ["bash", "start_docker.sh"]
docker-compose.yml:
version: '3.8'
services:
baby-sleep-coach:
build:
dockerfile: Dockerfile
context: .
ports:
- "0.0.0.0:80:80"
- "0.0.0.0:8000:8000"
- "0.0.0.0:8001:8001"
env_file:
- .env
volumes:
- "./main.py:/usr/app/babysleepcoach/main.py"
- "./sleep_logs.csv:/usr/app/babysleepcoach/sleep_logs.csv"
- "./user_defined_crop_area.txt:/usr/app/babysleepcoach/user_defined_crop_area.txt"
Looking forward to any insights or suggestions from the community on how to resolve this issue. Thank you!
@Megaptera666 if you're still blocked by this, do you mind checking your network tab & letting me know if all your calls to port :8000 and :8001 are red like @albvar highlighted in his comment? A lot of the communication between web app & server was hackily and hastily done, not proud of that work :) I'm hoping to find time to circle back and make this less error prone on initial configuration
Hi I am also having the same issue. So I tried to follow the steps @albvar provided. Still seems to be getting the same error. If someone can help me out I would really appreciate it.
This is my .env file settings
CAM_URL=rtsp://crib:cam@192.168.2.172:554/stream1 # full url of the baby camera APP_DIR=/usr/app/babysleepcoach # location of app root, primarily used for docker DEBUG=False OWL=False # lol VIDEO_PATH=/usr/app/babysleepcoach/video # for debugging & testing HATCH_IP=192.168.HATCH.IP # optional REACT_APP_BACKEND_IP=192.168.2.53:7001 # ip of flask server. This is the ip of "this" machine running the system REACT_APP_RESOURCE_SERVER_IP=192.168.2.53:7000 # ip of resource server (TODO: align to 1 server). This is the ip of "this" machine running the system PORT=85 # port web app serves assets from
What does your 'start_docker.sh' look like?
#!/bin/bash
#yarn --cwd webapp start && python3 main.py
#!/bin/bash
# Start the Node.js app in the background
yarn --cwd webapp start &
# Start the app
python3 main.py
And this is my dockerfile
FROM node:slim
WORKDIR /usr/app/babysleepcoach
EXPOSE 85
#Copy all files in the container
COPY . .
# Install required packages
ENV PIP_BREAK_SYSTEM_PACKAGES 1
RUN apt-get update && apt-get install python3-pip libgl1 libglib2.0-0 -y
RUN pip3 install --upgrade pip
RUN pip3 install -r requirements.txt
RUN cd webapp && yarn install && cd ..
WORKDIR /usr/app/babysleepcoach
ENTRYPOINT ["bash", "start_docker.sh"]
What about your docker logs and docker-compose.ynl
It's all this
Bounds not set, not running AI logic. Bounds not set, not running AI logic. Bounds not set, not running AI logic. Bounds not set, not running AI logic. Bounds not set, not running AI logic. Bounds not set, not running AI logic.
Can you install apt install net-tools then net stat -tuln
Ok will give it a try thanks, btw I just noticed that my docker-compose is not updated similar to yours. Could that have an impact? This is what I have
services:
baby-sleep-coach:
build:
dockerfile: ./Dockerfile
context: .
ports:
- "0.0.0.0:85:85"
- "0.0.0.0:7000:7000"
- "0.0.0.0:7001:7001"
env_file:
- .env
volumes:
- type: bind
# You need to update this to absolute path of this dir on your machine
source: /home/supun/BabySleepCoach
target: "${APP_DIR}"
# To use a webcam, uncomment these lines
# devices:
# - /dev/video0
Mimic my compose file for volume instead, this overwrites
Sorry for all the setup issues. I just finished moving, and will nuke my existing environment and setup from scratch as you are, so I can identify and iron out issues like this. Hopefully I can tighten up the setup process.
"Bounds not set, not running AI logic." Goes away once you set the bounding box that the system "watches", in the web app. You can comment out that print() in the code and rebuild, if it's annoying/covering up another error.
Still rebuilding, hopefully it works now. Thanks for helping me out and @calebolson123 no need to be sorry, thank you very much for creating this project.
Run it inside the container
docker ps # get running containers and grab id
docker exec -it <containerid> /bin/bash
apt install net-tools
netstat -tuln
start_docker.sh
python3 main.sh
inside of start_docker.sh
Ports will differ based on what you defined inside the config files
So mine should be opening ports 7000 and 7001 instead of 8000 and 8001. I think that's the issue.
The docker-compose and .env files have the ports set to 7000 and 7001. Is it because the main.py has the ports hardcoded in it?
The docker-compose and .env files have the ports set to 7000 and 7001. Is it because the main.py has the ports hardcoded in it?
I think you are right about it being hardcoded. I would recommend hosting a dedicated docker environment and stick with the defaults or pivot and use 8000,8001 within the relevant files .env
and docker-compose.yml
I modified the main.py file and changed them to my ports (7000,7001) and it's working now. Thank you for helping me troubleshoot it.
@albvar do you mind giving me a hand with my issue #35 . I am not getting a video feed and tried some of your suggestions
I'm having a similar issue to @albvar and can't figure it out. My compose, and startdocker files all look the same as his. Exact same errors thrown up as @supunw yet my ports on net stats are 8000,8001, same as the main.py file.
Hey Caleb, awesome project! I have been trying to set it up but cant figure out the last step or two, and I was hoping you could give me a pointer or two. So far I have:
-> I set up the rtsp stream using some rapberry pi and a camera. I know the stream works because I can read it and display it from another device.
-> I configured the .env file in the cloned repo accordingly.
-> I installed docker, and built the container (no errors)
-> I installed node.js and yarn, upgrading them to the latest version (>12), and ran "yarn install" and "yarn start" from the webapp directory. **to make this work I changed line 25 in the package.json file from "start&" tpo "start" (not shure this ws a typo).
=> everything appears to build successfully, a new webpage pops up at port 3000 and the blue GUI appears, but as soon as it looks like it will start working the screen turns red and the following error apperars:
Failed to fetch TypeError: Failed to fetch at getSleepNotificationsEnabled (http://localhost:3000/static/js/bundle.js:1023:34) at Settings (http://localhost:3000/static/js/bundle.js:1027:36) at renderWithHooks (http://localhost:3000/static/js/bundle.js:79874:22) at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:83160:17) at beginWork (http://localhost:3000/static/js/bundle.js:84456:20) at beginWork$1 (http://localhost:3000/static/js/bundle.js:89419:18) at performUnitOfWork (http://localhost:3000/static/js/bundle.js:88688:16) at workLoopSync (http://localhost:3000/static/js/bundle.js:88611:9) at renderRootSync (http://localhost:3000/static/js/bundle.js:88584:11) at performConcurrentWorkOnRoot (http://localhost:3000/static/js/bundle.js:87978:78)
So it looks like its not being able to grab the frames from the stream? Any idea what might be wrong or what am I missing? I have tried both from my pc and the raspberry pi4 with identical results (by the way, were you actually able to run this in a raspberry pi 4?)
Thanks for your help and for setting this up, its really cool!