Yashwanthsairam commited on
Commit
9be53ab
·
verified ·
1 Parent(s): d470904

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +39 -14
Dockerfile CHANGED
@@ -1,23 +1,48 @@
1
- # Use a minimal base image with Python 3.9 installed
2
- FROM python:3.9
3
 
4
- # Set the working directory inside the container to /app
5
- WORKDIR /app
 
 
 
 
6
 
7
- # Copy all files from the current directory on the host to the container's /app directory
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  COPY . .
9
 
10
- # Install Python dependencies listed in requirements.txt
11
- RUN pip3 install -r requirements.txt
12
 
13
- RUN useradd -m -u 1000 user
14
  USER user
15
  ENV HOME=/home/user \
16
- PATH=/home/user/.local/bin:$PATH
17
-
18
- WORKDIR $HOME/app
19
 
20
- COPY --chown=user . $HOME/app
 
 
21
 
22
- # Define the command to run the Streamlit app on port "8501" and make it accessible externally
23
- CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
 
 
 
 
 
 
 
1
+ # Hugging Face Docker Space - Streamlit (port 7860)
2
+ FROM python:3.9-slim
3
 
4
+ # -----------------------------
5
+ # System setup
6
+ # -----------------------------
7
+ ENV PYTHONDONTWRITEBYTECODE=1 \
8
+ PYTHONUNBUFFERED=1 \
9
+ PIP_NO_CACHE_DIR=1
10
 
11
+ # Create a non-root user (HF-friendly)
12
+ RUN useradd -m -u 1000 user
13
+
14
+ # -----------------------------
15
+ # App setup
16
+ # -----------------------------
17
+ WORKDIR /home/user/app
18
+
19
+ # Copy requirements first (better Docker layer caching)
20
+ COPY requirements.txt ./requirements.txt
21
+
22
+ # Install Python dependencies
23
+ RUN pip install --upgrade pip && pip install -r requirements.txt
24
+
25
+ # Copy application code
26
  COPY . .
27
 
28
+ # Fix ownership (optional but recommended)
29
+ RUN chown -R user:user /home/user/app
30
 
31
+ # Switch to non-root user
32
  USER user
33
  ENV HOME=/home/user \
34
+ PATH=/home/user/.local/bin:$PATH
 
 
35
 
36
+ # Hugging Face expects the service on port 7860
37
+ ENV PORT=7860
38
+ EXPOSE 7860
39
 
40
+ # -----------------------------
41
+ # Run Streamlit
42
+ # -----------------------------
43
+ CMD ["streamlit", "run", "app.py", \
44
+ "--server.address=0.0.0.0", \
45
+ "--server.port=7860", \
46
+ "--server.headless=true", \
47
+ "--browser.gatherUsageStats=false", \
48
+ "--server.enableXsrfProtection=false"]