tueniuu commited on
Commit
7c29d13
·
verified ·
1 Parent(s): 80ace75

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -7
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  # 1. Use an official lightweight Python image
2
  FROM python:3.9-slim
3
 
4
- # 2. Set environment variables to prevent Python from buffering stdout/stderr
5
  ENV PYTHONUNBUFFERED=1 \
6
  PYTHONDONTWRITEBYTECODE=1 \
7
  PIP_NO_CACHE_DIR=1
@@ -14,7 +14,7 @@ ENV PATH="/home/user/.local/bin:$PATH"
14
  # 4. Set the working directory
15
  WORKDIR /app
16
 
17
- # 5. Install system dependencies (Git is often needed for cloning repos)
18
  USER root
19
  RUN apt-get update && apt-get install -y \
20
  git \
@@ -22,7 +22,7 @@ RUN apt-get update && apt-get install -y \
22
  && rm -rf /var/lib/apt/lists/*
23
  USER user
24
 
25
- # 6. Copy requirements first (to leverage Docker caching)
26
  COPY --chown=user requirements.txt ./
27
 
28
  # 7. Install Python dependencies
@@ -30,11 +30,15 @@ RUN pip install --upgrade pip && \
30
  pip install -r requirements.txt
31
 
32
  # 8. Copy the rest of the application files
33
- # This includes app.py and your .pkl model files
34
  COPY --chown=user . .
35
 
36
- # 9. Expose the port Hugging Face Spaces expects (7860)
37
  EXPOSE 7860
38
 
39
- # 10. Run the Streamlit app on port 7860
40
- CMD ["streamlit", "run", "app.py", "--server.address", "0.0.0.0", "--server.port", "7860"]
 
 
 
 
 
 
1
  # 1. Use an official lightweight Python image
2
  FROM python:3.9-slim
3
 
4
+ # 2. Set environment variables
5
  ENV PYTHONUNBUFFERED=1 \
6
  PYTHONDONTWRITEBYTECODE=1 \
7
  PIP_NO_CACHE_DIR=1
 
14
  # 4. Set the working directory
15
  WORKDIR /app
16
 
17
+ # 5. Install system dependencies
18
  USER root
19
  RUN apt-get update && apt-get install -y \
20
  git \
 
22
  && rm -rf /var/lib/apt/lists/*
23
  USER user
24
 
25
+ # 6. Copy requirements first
26
  COPY --chown=user requirements.txt ./
27
 
28
  # 7. Install Python dependencies
 
30
  pip install -r requirements.txt
31
 
32
  # 8. Copy the rest of the application files
 
33
  COPY --chown=user . .
34
 
35
+ # 9. Expose the port
36
  EXPOSE 7860
37
 
38
+ # 10. Run the Streamlit app (WITH THE SECURITY FIXES)
39
+ CMD ["streamlit", "run", "app.py", \
40
+ "--server.address", "0.0.0.0", \
41
+ "--server.port", "7860", \
42
+ "--server.enableXsrfProtection=false", \
43
+ "--server.enableCORS=false", \
44
+ "--server.fileWatcherType", "none"]