DSatishchandra commited on
Commit
b5267d4
·
verified ·
1 Parent(s): b0ba6ac

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -2
Dockerfile CHANGED
@@ -16,6 +16,8 @@ RUN apt-get update && apt-get install -y \
16
 
17
  # Create a non-root user to avoid permission issues
18
  RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
 
 
19
  USER appuser
20
 
21
  # Set environment variables for Streamlit and Hugging Face
@@ -23,6 +25,7 @@ ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
23
  ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
24
  ENV HF_HOME=/app/.cache/huggingface
25
  ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE=none
 
26
 
27
  # Create necessary directories with correct permissions
28
  RUN mkdir -p /app/.streamlit /app/.cache/huggingface
@@ -30,7 +33,11 @@ RUN chmod -R 777 /app/.streamlit /app/.cache
30
 
31
  # Copy the requirements and install them
32
  COPY --chown=appuser:appuser requirements.txt ./
33
- RUN pip3 install --no-cache-dir -r requirements.txt
 
 
 
 
34
 
35
  # Copy the source code and modules directory
36
  COPY --chown=appuser:appuser src/ ./src/
@@ -43,4 +50,4 @@ EXPOSE 8501
43
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
44
 
45
  # Set the entry point to run the Streamlit app
46
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
16
 
17
  # Create a non-root user to avoid permission issues
18
  RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
19
+
20
+ # Switch to non-root user
21
  USER appuser
22
 
23
  # Set environment variables for Streamlit and Hugging Face
 
25
  ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
26
  ENV HF_HOME=/app/.cache/huggingface
27
  ENV STREAMLIT_SERVER_FILE_WATCHER_TYPE=none
28
+ ENV PATH=/home/appuser/.local/bin:$PATH
29
 
30
  # Create necessary directories with correct permissions
31
  RUN mkdir -p /app/.streamlit /app/.cache/huggingface
 
33
 
34
  # Copy the requirements and install them
35
  COPY --chown=appuser:appuser requirements.txt ./
36
+ RUN pip3 install --user --no-cache-dir -r requirements.txt
37
+ RUN pip3 install --user --no-cache-dir streamlit
38
+
39
+ # Verify Streamlit installation
40
+ RUN streamlit --version || { echo "Streamlit installation failed"; exit 1; }
41
 
42
  # Copy the source code and modules directory
43
  COPY --chown=appuser:appuser src/ ./src/
 
50
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
51
 
52
  # Set the entry point to run the Streamlit app
53
+ ENTRYPOINT ["/home/appuser/.local/bin/streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]