amritn8 commited on
Commit
de234f8
·
verified ·
1 Parent(s): 3eef734

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -19
Dockerfile CHANGED
@@ -1,8 +1,11 @@
1
- # Use official Python image as base
2
  FROM python:3.9-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
 
 
 
6
 
7
  # Install system dependencies
8
  RUN apt-get update && \
@@ -11,27 +14,20 @@ RUN apt-get update && \
11
  python3-dev \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
- # Create cache directory with proper permissions
15
- RUN mkdir -p /app/model_cache && chmod a+rwx /app/model_cache
16
 
17
- # Set environment variables for cache locations
18
- ENV TRANSFORMERS_CACHE=/app/model_cache
19
- ENV HF_HOME=/app/model_cache
20
-
21
- # Copy requirements first to leverage Docker cache
22
  COPY requirements.txt .
23
-
24
- # Install Python dependencies
25
- RUN pip install --no-cache-dir -r requirements.txt
26
-
27
- # Copy the application
28
  COPY app.py .
29
 
30
- # Expose the port Streamlit runs on
31
- EXPOSE 8501
 
32
 
33
- # Health check
34
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
 
 
35
 
36
- # Run the application
37
  CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use lightweight Python image
2
  FROM python:3.9-slim
3
 
4
+ # Set up environment
5
  WORKDIR /app
6
+ ENV PYTHONUNBUFFERED=1 \
7
+ TRANSFORMERS_CACHE=/app/model_cache \
8
+ HF_HOME=/app/model_cache
9
 
10
  # Install system dependencies
11
  RUN apt-get update && \
 
14
  python3-dev \
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Create cache directory with write permissions
18
+ RUN mkdir -p /app/model_cache && chmod 777 /app/model_cache
19
 
20
+ # Copy only necessary files
 
 
 
 
21
  COPY requirements.txt .
 
 
 
 
 
22
  COPY app.py .
23
 
24
+ # Install Python packages
25
+ RUN pip install --no-cache-dir -r requirements.txt && \
26
+ python -c "from transformers import pipeline; pipeline('question-answering', model='distilbert-base-uncased-distilled-squad')"
27
 
28
+ # Expose and run
29
+ EXPOSE 8501
30
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
31
+ CMD curl -f http://localhost:8501/_stcore/health || exit 1
32
 
 
33
  CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]