Keeby-smilyai commited on
Commit
41c0043
·
verified ·
1 Parent(s): b0d028c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -17
Dockerfile CHANGED
@@ -6,29 +6,33 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
6
  ffmpeg \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- # Set working directory
10
- WORKDIR /app
11
 
12
- # Copy app files
13
- COPY . /app
 
 
 
 
14
 
15
- # Install Python dependencies
16
- RUN pip install --no-cache-dir -r requirements.txt
17
 
18
- # Disable Streamlit usage stats to avoid permission issues with ~/.streamlit
19
- ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=0
20
 
21
- # Set HOME to avoid root directory writes
22
- ENV HOME=/root
23
 
24
- # Create .streamlit dir if needed (though env var should suffice)
25
- RUN mkdir -p /root/.streamlit
26
 
27
- # Expose Streamlit port
28
- EXPOSE 8501
29
 
30
  # Health check
31
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
32
 
33
- # Run the app
34
- CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
6
  ffmpeg \
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Create non-root user for Hugging Face Spaces compatibility
10
+ RUN useradd -m -u 1000 user
11
 
12
+ # Set environment variables
13
+ ENV HOME=/home/user \
14
+ PATH=/home/user/.local/bin:$PATH \
15
+ PYTHONUNBUFFERED=1 \
16
+ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
17
+ HF_HOME=/tmp/huggingface_cache
18
 
19
+ # Set working directory
20
+ WORKDIR $HOME/app
21
 
22
+ # Copy files as non-root user
23
+ COPY --chown=user . $HOME/app
24
 
25
+ # Install Python dependencies as non-root user
26
+ RUN pip install --no-cache-dir --user -r requirements.txt
27
 
28
+ # Switch to non-root user
29
+ USER user
30
 
31
+ # Expose Streamlit port (use 7860 for default HF Spaces, or specify app_port in README.md)
32
+ EXPOSE 7860
33
 
34
  # Health check
35
+ HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1
36
 
37
+ # Run the app (adjust port to 7860 for HF Spaces default)
38
+ CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]