Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -7
Dockerfile
CHANGED
|
@@ -23,16 +23,18 @@ RUN mkdir -p $NLTK_DATA
|
|
| 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 |
-
#
|
| 27 |
-
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
RUN chmod -R 755 models artifacts vectorizers
|
| 32 |
|
| 33 |
-
# Create
|
| 34 |
-
RUN
|
| 35 |
RUN chown -R user:user /app
|
|
|
|
|
|
|
|
|
|
| 36 |
USER user
|
| 37 |
|
| 38 |
# Set environment variables
|
|
@@ -44,5 +46,8 @@ ENV HOME=/home/user \
|
|
| 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"]
|
|
|
|
| 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
|
|
|
|
| 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"]
|