the problem is even thought I’m quite sure the value im passing as URL_LAUNCHER_URL is correct, when the python script start, from chromium I’m unable to see the frontend hosted by the frontend container, while if i type for example https://youtube.com as URL_LAUNCHER_URL chromium open without problem the web page.
Can someone help me understand the cause of the error and help me resolve it?
yes, if it could be of any help im going to share the 2 dockerfile im using in the docker-compose:
chromium service dockerfile:
FROM balenalib/raspberrypi4-64-debian-python:3.10-sid-build
ENV container docker
# Install necessary dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
apt-utils \
curl \
dbus \
wget \
xserver-xorg-core \
xserver-xorg-legacy \
xserver-xorg-input-all \
xserver-xorg-video-fbdev \
x11-xserver-utils \
xorg \
libxcb-image0 \
libxcb-util0-dev \
xdg-utils \
libdbus-1-dev \
libcap-dev \
libxtst-dev \
libxss1 \
lsb-release \
fbset \
systemd-sysv \
libexpat-dev \
libgles2-mesa \
libsdl2-dev \
chromium \
nodejs \
npm \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install serve globally
RUN npm install -g serve
# Set up X11 configuration
RUN echo "#!/bin/bash" > /etc/X11/xinit/xserverrc \
&& echo "" >> /etc/X11/xinit/xserverrc \
&& echo 'exec /usr/bin/X -s 0 dpms -nocursor -nolisten tcp "$@"' >> /etc/X11/xinit/xserverrc
# Mask unnecessary systemd services
RUN systemctl mask -- \
dev-hugepages.mount \
sys-fs-fuse-connections.mount \
sys-kernel-config.mount \
display-manager.service \
getty@.service \
systemd-logind.service \
systemd-remount-fs.service \
getty.target \
graphical.target \
systemd-journald.service \
systemd-udevd.service
# Copy entry script and systemd service file
COPY entry.sh /usr/bin/entry.sh
COPY balena.service /etc/systemd/system/balena.service
# Remove executable permission from systemd service file
RUN chmod -x /etc/systemd/system/balena.service
# Enable the systemd service
RUN systemctl enable /etc/systemd/system/balena.service
# Set the stop signal
STOPSIGNAL 37
# Set the entry point
ENTRYPOINT ["/usr/bin/entry.sh"]
# Set the working directory
WORKDIR /usr/src/app
# Copy the application files
COPY ./app ./
# Install pm2 globally
#RUN npm install -g pm2
# Start app using pm2
CMD ["bash" "start.sh"]
frontend dockerfile
FROM python:3.10
# Install system dependencies
RUN apt-get update && apt-get install -y libgl1-mesa-glx libatomic1
RUN pip install --upgrade tensorflow
# Upgrade pip
RUN pip install --upgrade pip
RUN usermod -aG video root
# Copy requirements and install dependencies
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
# Copy the rest of the application code
COPY . /app
# Expose the Flask port
EXPOSE 5000
EXPOSE 8000
# Set environment variable to avoid issues with TensorFlow
ENV LD_PRELOAD /usr/lib/aarch64-linux-gnu/libatomic.so.1
# Run the Flask application
CMD [ "flask", "run" ]
@giacomo00
Try putting the URL http://frontend:8000 or http://ip_address_of_your_balena_device:8000.
The only problem I can see is you have mapped your frontend container port 5000 to the host’s port 8000. I could be wrong though.
One thing you can do in your docker-compose is run the chromium container after your frontend container has started to ensure that when the chromium browser opens the URL, your website server has started executing.
If anyone finds a mistake in my answer please point it out.
Thank you
same result, one question, because i dont know a thing about python, is it possible that even if it print this:
Directory /root/.deepface created
Directory /root/.deepface/weights created
* Ignoring a call to 'app.run()' that would block the current 'flask' CLI command.
Only call 'app.run()' in an 'if __name__ == "__main__"' guard.
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
@giacomo00 Binding Address : The Flask server is running on http://127.0.0.1:5000 . This IP address (127.0.0.1 ) refers to localhost within the container, not the host machine. To make the Flask application accessible from outside the container, you need to bind it to 0.0.0.0 instead. This makes the server listen to all public IPs, allowing access from outside the container. App.run() in Flask: The warning about “app.run() in a Flask CLI command” is important. Ensure that you start your Flask app properly. It should be something like this:
if name == “main”:
app.run(host=‘0.0.0.0’, port=5000)
This ensures that app.run() is only called when you’re running the script directly and not on import. Also, setting host=‘0.0.0.0’ makes the server accessible externally.
where do i have to specify the host=‘0.0.0.0’?
as i said i dont know a thing of python and the script wasnt done by me, but from one of my colleagues, i have found only a 127.0.0.1 in the frontend script and it is in app.js, is it there where i have to put 0.0.0.0 or its in another point?
@giacomo00
You can change this in your python dockerfile and also change every occurrence of 127.0.0.1:5000 to 0.0.0.0:5000 inside your frontend folder
change this to
CMD [“flask”, “run”, “–host=0.0.0.0”, “–port=8000”]
Before doing any changes please save a copy of your original file if something goes wrong