pykara commited on
Commit
3250bcb
·
verified ·
1 Parent(s): b4174e8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -15
Dockerfile CHANGED
@@ -5,16 +5,29 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
5
  DEBIAN_FRONTEND=noninteractive \
6
  PIP_NO_CACHE_DIR=1
7
 
8
- # System deps for builds (lxml, numpy/scipy), plus tools
9
- RUN apt-get update && apt-get install -y --no-install-recommends \
10
- build-essential curl wget git \
11
- libxml2-dev libxslt1-dev zlib1g-dev \
12
- libjpeg-dev libpng-dev \
13
- libopenblas-dev liblapack-dev gfortran \
14
- ca-certificates && \
 
 
 
 
 
 
 
 
 
 
 
15
  rm -rf /var/lib/apt/lists/*
16
 
17
- # Build and install TA-Lib (C library) — robust to varying extract dir names
 
 
18
  RUN set -ex \
19
  && curl -fsSL -o /tmp/ta-lib.tgz http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
20
  && tar -xzf /tmp/ta-lib.tgz -C /tmp \
@@ -26,23 +39,25 @@ RUN set -ex \
26
 
27
  WORKDIR /app
28
 
29
- # Python deps first (better layer caching)
 
 
30
  COPY requirements.txt /app/requirements.txt
31
  RUN python -m pip install --upgrade pip && \
32
  pip install --no-cache-dir -r /app/requirements.txt
33
 
34
- # PyTorch (CPU wheels from official index)
35
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
36
  torch torchvision torchaudio
37
 
38
- # Pre-fetch NLTK data used by your code (VADER)
39
  ENV NLTK_DATA=/usr/local/share/nltk_data
40
  RUN mkdir -p "$NLTK_DATA" && \
41
  python -c "import nltk; nltk.download('vader_lexicon', download_dir='$NLTK_DATA')"
42
 
43
- # Copy the application code
44
  COPY . /app
45
 
46
- # Start with gunicorn; HF provides $PORT
47
- # If your app object is named "app" in "pytrade.py", this is correct.
48
- CMD bash -lc "gunicorn -w 1 -k gthread -b 0.0.0.0:${PORT:-7860} pytrade:app --timeout 180"
 
5
  DEBIAN_FRONTEND=noninteractive \
6
  PIP_NO_CACHE_DIR=1
7
 
8
+ # --------------------------------------------------------------------
9
+ # System deps for builds (numpy/scipy, lxml, TA-Lib) + unixODBC + MS ODBC
10
+ # --------------------------------------------------------------------
11
+ RUN set -eux; \
12
+ apt-get update; \
13
+ apt-get install -y --no-install-recommends \
14
+ build-essential curl wget git ca-certificates gnupg apt-transport-https \
15
+ libxml2-dev libxslt1-dev zlib1g-dev \
16
+ libjpeg-dev libpng-dev \
17
+ libopenblas-dev liblapack-dev gfortran \
18
+ unixodbc unixodbc-dev; \
19
+ # Microsoft repo for SQL Server ODBC driver 18
20
+ curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -; \
21
+ . /etc/os-release; \
22
+ echo "deb [arch=amd64] https://packages.microsoft.com/debian/${VERSION_CODENAME}/prod ${VERSION_CODENAME} main" \
23
+ > /etc/apt/sources.list.d/microsoft-prod.list; \
24
+ apt-get update; \
25
+ ACCEPT_EULA=Y apt-get install -y --no-install-recommends msodbcsql18 mssql-tools18; \
26
  rm -rf /var/lib/apt/lists/*
27
 
28
+ # -------------------------------------------------
29
+ # Build and install TA-Lib C library (as you had)
30
+ # -------------------------------------------------
31
  RUN set -ex \
32
  && curl -fsSL -o /tmp/ta-lib.tgz http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
33
  && tar -xzf /tmp/ta-lib.tgz -C /tmp \
 
39
 
40
  WORKDIR /app
41
 
42
+ # --------------------------
43
+ # Python deps (layer cache)
44
+ # --------------------------
45
  COPY requirements.txt /app/requirements.txt
46
  RUN python -m pip install --upgrade pip && \
47
  pip install --no-cache-dir -r /app/requirements.txt
48
 
49
+ # PyTorch CPU
50
  RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu \
51
  torch torchvision torchaudio
52
 
53
+ # NLTK data
54
  ENV NLTK_DATA=/usr/local/share/nltk_data
55
  RUN mkdir -p "$NLTK_DATA" && \
56
  python -c "import nltk; nltk.download('vader_lexicon', download_dir='$NLTK_DATA')"
57
 
58
+ # App code
59
  COPY . /app
60
 
61
+ # Gunicorn entrypoint (Hugging Face sets $PORT)
62
+ CMD ["bash", "-lc", "gunicorn -w 1 -k gthread -b 0.0.0.0:${PORT:-7860} pytrade:app --timeout 180"]
63
+