Hi, I'm trying to run Streamlit in Docker. To run...
# general
h
Hi, I'm trying to run Streamlit in Docker. To run the Streamlit app locally, I use this pex binary configuration:
Copy code
pex_binary(
    name="bin",
    script="streamlit",
    args=["run", "projects/test/main.py", "--server.port", "8501", "--global.developmentMode", "false"],
    dependencies=[":source"],
    execution_mode="venv",
    restartable=True,
)
However, because the path in the run command points to the local filesystem this does not work when I use the pex in a Docker container. To make it work in the container, I have to change the args to point to the main file in the python env site packages like so:
Copy code
args=["run", "lib/python3.11/site-packages/test/main.py", "--server.port", "8501", "--global.developmentMode", "false", "--server.address", "0.0.0.0"]
Is there a better way to accomplish this? I imagine people using gunicorn or something similar where a python file needs to be passed as an argument to the actual program would run into the same issue?
b
Because streamlit does not accept a python module as an argument, I just add an additional
file(name="main", source="main.py")
target and added that to the docker dependencies + Dockerfile.