Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +4 -46
Dockerfile
CHANGED
|
@@ -1,48 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
FROM python:3.9-slim
|
| 3 |
-
|
| 4 |
-
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
-
|
| 7 |
-
|
| 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"]
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
|
|
|
|
|
|
|
|
|
| 2 |
WORKDIR /app
|
| 3 |
+
COPY requirements.txt .
|
| 4 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
COPY . .
|
| 6 |
+
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|