Alamgirapi commited on
Commit
cb7e73c
·
verified ·
1 Parent(s): f238bbd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -7
Dockerfile CHANGED
@@ -16,20 +16,33 @@ RUN apt-get update && apt-get install -y \
16
  COPY requirements.txt ./
17
  RUN pip3 install --no-cache-dir -r requirements.txt
18
 
19
- # Download NLTK data
20
- RUN python -c "import nltk; nltk.download('punkt'); nltk.download('stopwords'); nltk.download('vader_lexicon')"
 
 
 
 
21
 
22
  # Copy the application code
23
  COPY . .
24
 
25
- # Create necessary directories
26
- RUN mkdir -p models artifacts
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  # Expose the port that Streamlit runs on
29
  EXPOSE 8501
30
 
31
- # Add health check
32
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
33
-
34
  # Run the application
35
  CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
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"]