akashjayampu commited on
Commit
f10b6d1
·
verified ·
1 Parent(s): 0d5deaa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -14
Dockerfile CHANGED
@@ -1,34 +1,34 @@
1
- # Use lightweight Python base image
2
  FROM python:3.9-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Install dependencies
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  git \
11
  curl \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Copy code
15
  COPY requirements.txt ./
16
  COPY src/ ./src/
17
 
18
  # Install Python dependencies
19
  RUN pip install --upgrade pip && pip install -r requirements.txt
20
 
21
- # Set environment variables
22
  ENV HF_HOME=/app/.cache/huggingface
23
  ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
24
- ENV HF_TOKEN=hf_your_token_here # ⛔ REPLACE below in build step instead, safer
25
 
26
- # Setup authentication to Hugging Face gated models
27
- RUN pip install huggingface_hub && \
28
- echo "machine huggingface.co\n login $HF_TOKEN" > /root/.netrc && \
29
- chmod 600 /root/.netrc
30
 
31
- # Preload Mistral model and sentiment model
 
 
 
32
  RUN python3 -c "from transformers import pipeline; \
33
  pipeline('summarization', model='mistralai/Mistral-7B-Instruct-v0.1', \
34
  tokenizer='mistralai/Mistral-7B-Instruct-v0.1', \
@@ -36,11 +36,9 @@ RUN python3 -c "from transformers import pipeline; \
36
  python3 -c "from transformers import pipeline; \
37
  pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')"
38
 
39
- # Expose Streamlit default port
40
  EXPOSE 8501
41
-
42
- # Health check
43
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
44
 
45
- # Launch Streamlit app
46
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use slim Python image
2
  FROM python:3.9-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  git \
11
  curl \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Copy app files
15
  COPY requirements.txt ./
16
  COPY src/ ./src/
17
 
18
  # Install Python dependencies
19
  RUN pip install --upgrade pip && pip install -r requirements.txt
20
 
21
+ # Environment for Hugging Face model caching
22
  ENV HF_HOME=/app/.cache/huggingface
23
  ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
 
24
 
25
+ # Accept token from build arguments (DON'T hardcode in Dockerfile)
26
+ ARG HF_TOKEN
 
 
27
 
28
+ # Setup Hugging Face authentication using token
29
+ RUN echo "machine huggingface.co\n login ${HF_TOKEN}" > /root/.netrc && chmod 600 /root/.netrc
30
+
31
+ # Pre-download gated Mistral and sentiment models
32
  RUN python3 -c "from transformers import pipeline; \
33
  pipeline('summarization', model='mistralai/Mistral-7B-Instruct-v0.1', \
34
  tokenizer='mistralai/Mistral-7B-Instruct-v0.1', \
 
36
  python3 -c "from transformers import pipeline; \
37
  pipeline('sentiment-analysis', model='distilbert-base-uncased-finetuned-sst-2-english')"
38
 
39
+ # Streamlit port and healthcheck
40
  EXPOSE 8501
 
 
41
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
42
 
43
+ # Run the Streamlit app
44
  ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]