Alamgirapi commited on
Commit
b136104
·
verified ·
1 Parent(s): a5bc77a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -36
Dockerfile CHANGED
@@ -1,7 +1,5 @@
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
@@ -9,45 +7,25 @@ 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
- # Create a non-root user first
27
- RUN useradd -m -u 1000 user
28
-
29
- # Copy the application code
30
- COPY --chown=user:user . .
31
-
32
- # Create necessary directories with proper permissions for the user
33
- RUN mkdir -p /app/models /app/artifacts /app/vectorizers
34
- RUN chown -R user:user /app
35
- RUN chmod -R 755 /app
36
-
37
- # Switch to non-root user
38
- USER user
39
 
40
  # Set environment variables
41
- ENV HOME=/home/user \
42
- PATH=/home/user/.local/bin:$PATH \
43
- PYTHONPATH=/app \
44
- NLTK_DATA=/usr/local/share/nltk_data
45
-
46
- # Expose the port that Streamlit runs on
47
- EXPOSE 8501
48
 
49
- # Health check
50
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
51
 
52
- # Run the application
53
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
 
7
  build-essential \
8
  curl \
9
  software-properties-common \
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Copy requirements first to leverage Docker cache
13
+ COPY requirements.txt .
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Copy the application
17
+ COPY . .
 
18
 
19
+ # Create directories for the app
20
+ RUN mkdir -p /tmp/app_data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  # Set environment variables
23
+ ENV STREAMLIT_SERVER_PORT=7860
24
+ ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
25
+ ENV STREAMLIT_SERVER_HEADLESS=true
26
+ ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE=none
27
+ ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
 
 
28
 
29
+ EXPOSE 7860
 
30
 
31
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]