Docker method issue: streamlit.errors.StreamlitAPIException: The image passed to st.logo is invalid
Describe the bug Deploy via docker, after docker container is up, visit http://localhost:8443 and see an error "streamlit.errors.StreamlitAPIException: The image passed to st.logo is invalid"
To Reproduce Steps to reproduce the behavior:
- clone the repository
- docker-compose up --build -d
- visit: http://localhost:8443
- See error
Expected behavior should see the web app start up page.
Screenshots
Desktop (please complete the following information):
- OS: Ubuntu (AMD X86)
- Browser [Chrome]
- Version [e.g. 22.04]
Additional context
- A close look at the log as enclosed below, the root cause is not finding docs/assets/logo.png as requested in /ultrarag/ultrarag/webui/webui.py", line 20.
- After log in to the container instance, the docs folder was not there inside /ultrarag.
- check Dockerfile which is used to build image, the full directory should be copied to the image
WORKDIR /ultrarag COPY . . - check .dockerignore, find docs folder is listed there, thus not being copied.
- after docker copy docs folder to docker instance, the web page is loaded successfully
app-1 | 2025-02-03 14:31:20.286 Uncaught app execution app-1 | Traceback (most recent call last): app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/elements/lib/image_utils.py", line 285, in image_to_url app-1 | with open(image, "rb") as f: app-1 | ^^^^^^^^^^^^^^^^^ app-1 | FileNotFoundError: [Errno 2] No such file or directory: 'docs/assets/logo.png' app-1 | app-1 | During handling of the above exception, another exception occurred: app-1 | app-1 | Traceback (most recent call last): app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/memory_media_file_storage.py", line 164, in _read_file app-1 | with open(filename, "rb") as f: app-1 | ^^^^^^^^^^^^^^^^^^^^ app-1 | FileNotFoundError: [Errno 2] No such file or directory: 'docs/assets/logo.png' app-1 | app-1 | The above exception was the direct cause of the following exception: app-1 | app-1 | Traceback (most recent call last): app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/commands/logo.py", line 139, in logo app-1 | image_url = image_to_url( app-1 | ^^^^^^^^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/elements/lib/image_utils.py", line 297, in image_to_url app-1 | url = runtime.get_instance().media_file_mgr.add(image, mimetype, image_id) app-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/media_file_manager.py", line 226, in add app-1 | file_id = self._storage.load_and_get_id( app-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/memory_media_file_storage.py", line 115, in load_and_get_id app-1 | file_data = self._read_file(path_or_data) app-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/memory_media_file_storage.py", line 167, in _read_file app-1 | raise MediaFileStorageError(f"Error opening '{filename}'") from ex app-1 | streamlit.runtime.media_file_storage.MediaFileStorageError: Error opening 'docs/assets/logo.png' app-1 | app-1 | The above exception was the direct cause of the following exception: app-1 | app-1 | Traceback (most recent call last): app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py", line 88, in exec_func_with_error_handling app-1 | result = func() app-1 | ^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 579, in code_to_exec app-1 | exec(code, module.__dict__) app-1 | File "/ultrarag/ultrarag/webui/webui.py", line 20, in <module> app-1 | st.logo( app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/runtime/metrics_util.py", line 409, in wrapped_func app-1 | result = non_optional_func(*args, **kwargs) app-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app-1 | File "/opt/miniconda/lib/python3.12/site-packages/streamlit/commands/logo.py", line 149, in logo app-1 | raise StreamlitAPIException(_invalid_logo_text("image")) from ex app-1 | streamlit.errors.StreamlitAPIException: The image passed to st.logo is invalid - See [documentation](https://docs.streamlit.io/develop/api-reference/media/st.logo) for more information on valid types app-1 | 2025-02-03 14:31:20.536 Examining the path of torch.classes raised: Tried to instantiate class '__path__._path', but it does not exist! Ensure that it is registered via torch::class_
Yes, you are right. When building the Docker image earlier, I forgot to copy the docs folder into the image, which caused the logo.png to be missing during runtime. I have now updated the copy rules, so this issue should be resolved. Thank you very much for your feedback!
Best regards!