here is my dockerfile
# Use an official Python base image
FROM intel/intel-optimized-pytorch:2.2.0-pip-base
# Set the working directory in the container
WORKDIR /app
# Copy the repository files into the container
COPY . /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
less \
nano \
pipx \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV POETRY_REQUESTS_TIMEOUT=300
# Install Poetry using pipx
RUN pipx install poetry==1.8.4 --verbose
# Add Poetry's binary directory to PATH
ENV PATH="/root/.local/pipx/venvs/poetry/bin:${PATH}"
# Install project dependencies
RUN poetry install --no-dev --no-interaction --no-ansi
# Install additional packages
RUN pip install --no-cache-dir sentence_transformers==3.3.1
# Copy the rest of the application code
COPY . .
# Expose the port that Streamlit will run on
EXPOSE 8501
# Set environment variables for Streamlit
ENV STREAMLIT_SERVER_PORT=8501
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
# Command to run the application
CMD ["poetry", "run", "streamlit", "run", "app.py"]
and my pyproject.toml
[tool.poetry]
name = "streamlit"
version = "0.1.0"
description = ""
authors = ["Alireza"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.10"
streamlit = "^1.42.0"
loguru = "^0.7.3"
pre-commit = "^4.1.0"
python-dotenv = "^1.0.1"
omegaconf = "^2.3.0"
numpy = "^2.2.2"
poetry-plugin-export = "^1.9.0"
watchdog = "^6.0.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
for some unknown reason, sometimes when I build the image, it takes ages and gives me time out error
326.4 TimeoutError
326.4
326.4 The read operation timed out
326.4
326.4 at /usr/lib/python3.10/ssl.py:1159 in read
326.4 1155│ if self._sslobj is None:
326.4 1156│ raise ValueError("Read on closed or unwrapped SSL socket.")
326.4 1157│ try:
326.4 1158│ if buffer is not None:
326.4 → 1159│ return self._sslobj.read(len, buffer)
326.4 1160│ else:
326.4 1161│ return self._sslobj.read(len)
326.4 1162│ except SSLError as x:
326.4 1163│ if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
326.4
326.4 The following error occurred when trying to handle this error:
326.4
326.4
326.4 ReadTimeoutError
326.4
326.4 HTTPSConnectionPool(host='files.pythonhosted', port=443): Read timed out.
326.4
326.4 at ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/urllib3/response.py:759 in _error_catcher
326.5 755│
326.5 756│ except SocketTimeout as e:
326.5 757│ # FIXME: Ideally we'd like to include the url in the ReadTimeoutError but
326.5 758│ # there is yet no clean way to get at it from this context.
326.5 → 759│ raise ReadTimeoutError(self._pool, None, "Read timed out.") from e # type: ignore[arg-type]
326.5 760│
326.5 761│ except BaseSSLError as e:
326.5 762│ # FIXME: Is there a better way to differentiate between SSLErrors?
326.5 763│ if "read operation timed out" not in str(e):
326.5
326.5 The following error occurred when trying to handle this error:
326.5
326.5
326.5 ConnectionError
326.5
326.5 HTTPSConnectionPool(host='files.pythonhosted', port=443): Read timed out.
326.5
326.5 at ~/.local/pipx/venvs/poetry/lib/python3.10/site-packages/requests/models.py:826 in generate
326.5 822│ raise ChunkedEncodingError(e)
326.5 823│ except DecodeError as e:
326.5 824│ raise ContentDecodingError(e)
326.5 825│ except ReadTimeoutError as e:
326.5 → 826│ raise ConnectionError(e)
326.5 827│ except SSLError as e:
326.5 828│ raise RequestsSSLError(e)
326.5 829│ else:
326.5 830│ # Standard file-like object.
326.5
326.5 Cannot install pandas.
326.5
------
Dockerfile:29
--------------------
27 |
28 | # Install project dependencies
29 | >>> RUN poetry install --no-dev --no-interaction --no-ansi
30 |
31 | # Install additional packages
--------------------
ERROR: failed to solve: process "/bin/bash -c poetry install --no-dev --no-interaction --no-ansi" did not complete successfully: exit code: 1
make: *** [docker-build] Error 1
I have increased the poetry time out as you can see by ENV POETRY_REQUESTS_TIMEOUT=300
but still the problem is there and it is not stable; I wonder how to circumvent and make it more stable
the error comes from => ERROR [6/8] RUN poetry install --no-dev --no-interaction --no-ansi