Solved
According to this: https://stackoverflow.com/a/57886655/15537469
and to this: https://stackoverflow.com/a/74918400/15537469
I make a Multi-stage Docker build with Poetry and venv
FROM python:3.10-buster as py-build
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python3 -
COPY . /app
WORKDIR /app
ENV PATH=/opt/poetry/bin:$PATH
RUN poetry config virtualenvs.in-project true && poetry install
FROM python:3.10-slim-buster
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
COPY --from=py-build /app /app
WORKDIR /app
CMD ./.venv/bin/python
ENTRYPOINT ["streamlit", "run", "mtcc/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
My build is going well but when I run my docker container I get this error: docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "streamlit": executable file not found in $PATH: unknown.
I don't know if this is really useful but here is my file structure
mtcc
├── mtcc
│ └── app.py
└── Dockerfile