Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +32 -13
Dockerfile
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
|
|
| 1 |
FROM python:3.9-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install system dependencies
|
|
@@ -7,25 +9,42 @@ RUN apt-get update && apt-get install -y \
|
|
| 7 |
build-essential \
|
| 8 |
curl \
|
| 9 |
software-properties-common \
|
|
|
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
# Copy requirements
|
| 13 |
-
COPY requirements.txt
|
| 14 |
-
RUN
|
| 15 |
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
-
# Create directories
|
| 20 |
-
RUN mkdir -p
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Set environment variables
|
| 23 |
-
ENV
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
-
EXPOSE 7860
|
| 30 |
|
| 31 |
-
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--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
|
|
|
|
| 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"]
|
| 49 |
|
|
|
|
| 50 |
|
|
|