Alamgirapi commited on
Commit
fdcfb8f
·
verified ·
1 Parent(s): b9fe56c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -6
Dockerfile CHANGED
@@ -1,20 +1,48 @@
1
- FROM python:3.13.5-slim
 
2
 
 
3
  WORKDIR /app
4
 
 
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
 
8
  git \
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
11
  COPY requirements.txt ./
12
- COPY src/ ./src/
13
 
14
- RUN pip3 install -r requirements.txt
 
 
15
 
16
- EXPOSE 8501
 
 
 
 
 
 
 
 
17
 
18
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
1
+ # Use Python 3.9 slim 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
  curl \
11
+ software-properties-common \
12
  git \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Copy requirements and install Python dependencies
16
  COPY requirements.txt ./
17
+ RUN pip3 install --no-cache-dir -r requirements.txt
18
 
19
+ # Set NLTK data directory to a location with proper permissions
20
+ ENV NLTK_DATA=/usr/local/share/nltk_data
21
+ RUN mkdir -p $NLTK_DATA
22
 
23
+ # Download NLTK data as root (with permissions) and handle SSL issues
24
+ RUN python -c "import ssl; ssl._create_default_https_context = ssl._create_unverified_context; import nltk; nltk.download('stopwords', download_dir='/usr/local/share/nltk_data'); nltk.download('wordnet', download_dir='/usr/local/share/nltk_data'); nltk.download('omw-1.4', download_dir='/usr/local/share/nltk_data')"
25
+
26
+ # Copy the application code
27
+ COPY . .
28
+
29
+ # Create necessary directories with proper permissions
30
+ RUN mkdir -p models artifacts vectorizers
31
+ RUN chmod -R 755 models artifacts vectorizers
32
 
33
+ # Create a non-root user for security
34
+ RUN useradd -m -u 1000 user
35
+ RUN chown -R user:user /app
36
+ USER user
37
+
38
+ # Set environment variables
39
+ ENV HOME=/home/user \
40
+ PATH=/home/user/.local/bin:$PATH \
41
+ PYTHONPATH=/app \
42
+ NLTK_DATA=/usr/local/share/nltk_data
43
+
44
+ # Expose the port that Streamlit runs on
45
+ EXPOSE 8501
46
 
47
+ # Run the application
48
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]