Entz commited on
Commit
1869a0e
·
verified ·
1 Parent(s): 01e5f06

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -18
Dockerfile CHANGED
@@ -1,28 +1,28 @@
1
- # Dockerfile
2
  FROM python:3.10-slim
3
 
 
4
  WORKDIR /app
5
- # tells the system to treat /app as the "home" directory, so Streamlit will create /app/.streamlit instead of /.streamlit.
6
- # /app is already writable as root, so no permission issues.
7
- ENV HOME=/app
8
 
 
 
 
9
 
 
 
 
 
10
 
11
- # (Optional) system deps if you need them; safe to remove if not needed
12
- RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
13
 
14
- # Install Python deps
15
- COPY requirements.txt /app/
16
- RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
17
 
18
- # Copy code
19
- COPY . /app
20
 
21
- # Do NOT set STREAMLIT_SERVER_PORT here.
22
- # Spaces will inject $PORT at runtime.
23
 
24
-
25
- # Start Streamlit on the port Spaces provides, and bind to 0.0.0.0
26
- # CMD ["bash", "-lc", "streamlit run /app/frontend.py --server.port $PORT --server.address 0.0.0.0"]
27
- # CMD ["sh", "-c", "streamlit run /app/frontend.py --server.port $PORT --server.address 0.0.0.0"]
28
- CMD ["streamlit", "run", "/app/frontend.py", "--server.port", "8501", "--server.address", "0.0.0.0"]
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Set working directory in the container
4
  WORKDIR /app
 
 
 
5
 
6
+ # Copy requirements and install dependencies
7
+ COPY requirements.txt .
8
+ RUN pip install --no-cache-dir -r requirements.txt
9
 
10
+ # Create group and non-root user for HF Spaces, then make /app writable
11
+ RUN addgroup --gid 1000 user && \
12
+ adduser --disabled-password --gecos '' --uid 1000 --gid 1000 user && \
13
+ chown -R user:user /app
14
 
15
+ # Copy application files
16
+ COPY . .
17
 
18
+ # Switch to non-root user
19
+ USER user
 
20
 
21
+ # Expose Streamlit port
22
+ EXPOSE 8501
23
 
24
+ # Health check for Streamlit
25
+ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
26
 
27
+ # Run Streamlit
28
+ CMD ["streamlit", "run", "frontend.py", "--server.port=8501", "--server.address=0.0.0.0"]