Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +36 -9
Dockerfile
CHANGED
|
@@ -3,28 +3,55 @@ FROM python:3.11-slim-bookworm
|
|
| 3 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
PIP_NO_CACHE_DIR=1 \
|
| 6 |
-
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
-
curl
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
COPY requirements.txt .
|
| 17 |
-
RUN python -m pip install --upgrade pip \
|
| 18 |
-
&& pip install --no-cache-dir --prefer-binary -r requirements.txt
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
COPY . .
|
| 22 |
|
| 23 |
ENV PORT=7860
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
-
#
|
| 27 |
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
| 28 |
CMD curl --fail http://127.0.0.1:${PORT}/_stcore/health || exit 1
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
| 3 |
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 4 |
PYTHONUNBUFFERED=1 \
|
| 5 |
PIP_NO_CACHE_DIR=1 \
|
| 6 |
+
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
| 7 |
+
# keep caches & matplotlib writable in containerized envs
|
| 8 |
+
XDG_CACHE_HOME=/tmp/.cache \
|
| 9 |
+
MPLCONFIGDIR=/tmp/matplotlib
|
| 10 |
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
+
# --- System deps: build tools + curl/wget and basic CA certs
|
| 14 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
+
build-essential curl wget ca-certificates \
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
+
# --- Build and install TA-Lib C library (0.4.0) ---
|
| 19 |
+
# The Python package needs this shared lib present at runtime.
|
| 20 |
+
RUN wget -O ta-lib-0.4.0-src.tar.gz http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
|
| 21 |
+
&& tar -xzf ta-lib-0.4.0-src.tar.gz \
|
| 22 |
+
&& cd ta-lib-0.4.0 \
|
| 23 |
+
&& ./configure --prefix=/usr \
|
| 24 |
+
&& make -j"$(nproc)" \
|
| 25 |
+
&& make install \
|
| 26 |
+
&& cd .. \
|
| 27 |
+
&& rm -rf ta-lib-0.4.0 ta-lib-0.4.0-src.tar.gz \
|
| 28 |
+
&& ldconfig
|
| 29 |
+
|
| 30 |
+
# --- Python deps in a safe order ---
|
| 31 |
+
# 1) Upgrade pip
|
| 32 |
+
RUN python -m pip install --upgrade pip
|
| 33 |
+
|
| 34 |
+
# 2) Copy requirements and install numpy first (headers available)
|
| 35 |
COPY requirements.txt .
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
# Install NumPy 1.26.4 explicitly first
|
| 38 |
+
RUN pip install --no-cache-dir --prefer-binary "numpy==1.26.4"
|
| 39 |
+
|
| 40 |
+
# 3) Install TA-Lib wrapper WITHOUT build isolation (so it uses the numpy we just installed)
|
| 41 |
+
RUN pip install --no-cache-dir --prefer-binary --no-build-isolation "TA-Lib==0.4.24"
|
| 42 |
+
|
| 43 |
+
# 4) Install the rest
|
| 44 |
+
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
|
| 45 |
+
|
| 46 |
+
# --- Your app code ---
|
| 47 |
COPY . .
|
| 48 |
|
| 49 |
ENV PORT=7860
|
| 50 |
EXPOSE 7860
|
| 51 |
|
| 52 |
+
# Healthcheck to help Spaces detect boot issues quickly
|
| 53 |
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
| 54 |
CMD curl --fail http://127.0.0.1:${PORT}/_stcore/health || exit 1
|
| 55 |
|
| 56 |
+
# Streamlit entrypoint
|
| 57 |
+
CMD ["sh", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=${PORT} --server.headless=true"]
|