Spaces:
Running
Running
change port to default
Browse files- 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 |
-
#
|
7 |
RUN useradd -m -u 1000 user
|
|
|
|
|
8 |
ENV PATH="/home/user/.local/bin:$PATH"
|
9 |
|
|
|
10 |
WORKDIR /app
|
11 |
COPY . .
|
12 |
|
13 |
-
# Install
|
14 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
15 |
|
16 |
-
#
|
17 |
-
|
|
|
18 |
|
19 |
-
#
|
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 |
-
|
29 |
-
|
30 |
-
" > /home/user/.streamlit/config.toml
|
31 |
|
32 |
-
#
|
33 |
-
|
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"]
|