myshirk commited on
Commit
0c5ab24
·
verified ·
1 Parent(s): bd6f067

change port to default

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -16
Dockerfile CHANGED
@@ -1,34 +1,33 @@
1
- # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
- # you will also find guides on how best to write your Dockerfile
3
-
4
  FROM python:3.9
5
 
6
- # Add non-root user and create working directories
7
  RUN useradd -m -u 1000 user
 
 
8
  ENV PATH="/home/user/.local/bin:$PATH"
9
 
 
10
  WORKDIR /app
11
  COPY . .
12
 
13
- # Install dependencies as root
14
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
 
16
- # Switch to user
17
- USER user
 
18
 
19
- # Pre-create .streamlit folder to avoid runtime errors
20
- RUN mkdir -p /home/user/.streamlit
21
-
22
- # Optional: add a default config to suppress Streamlit's warning
23
  RUN echo "\
24
  [server]\n\
25
  headless = true\n\
26
  enableCORS = false\n\
27
  enableXsrfProtection = false\n\
28
- port = 7860\n\
29
- address = \"0.0.0.0\"\n\
30
- " > /home/user/.streamlit/config.toml
31
 
32
- # Streamlit app entrypoint
33
- ENTRYPOINT ["streamlit", "run", "app.py"]
34
 
 
 
 
 
 
 
1
  FROM python:3.9
2
 
3
+ # Create a non-root user
4
  RUN useradd -m -u 1000 user
5
+
6
+ # Set PATH for pip user installs
7
  ENV PATH="/home/user/.local/bin:$PATH"
8
 
9
+ # Set working dir
10
  WORKDIR /app
11
  COPY . .
12
 
13
+ # Install Python deps
14
  RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
 
16
+ # Create .streamlit config directory
17
+ RUN mkdir -p /home/user/.streamlit && \
18
+ chown -R user:user /home/user/.streamlit
19
 
20
+ # Optional: add config.toml to suppress warnings
 
 
 
21
  RUN echo "\
22
  [server]\n\
23
  headless = true\n\
24
  enableCORS = false\n\
25
  enableXsrfProtection = false\n\
26
+ " > /home/user/.streamlit/config.toml && \
27
+ chown user:user /home/user/.streamlit/config.toml
 
28
 
29
+ # Switch to non-root user
30
+ USER user
31
 
32
+ # Run app using dynamic port from Hugging Face
33
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0", "--server.port=$PORT"]