File size: 922 Bytes
78a56d4
0d8ed45
78a56d4
 
0d8ed45
78a56d4
 
 
0d8ed45
78a56d4
 
 
0d8ed45
78a56d4
 
 
0d8ed45
78a56d4
 
0d8ed45
78a56d4
 
0d8ed45
78a56d4
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
FROM python:3.10

# 1. Set a temporary working directory
WORKDIR /code

# 2. Copy requirements and install them GLOBALLY (Prevents "Streamlit not found" errors)
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# 3. Create the restricted user required by Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user

# 4. Set up the user's safe environment variables
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:/usr/local/bin:$PATH

# 5. Set the working directory to the user's safe space
WORKDIR $HOME/app

# 6. Copy your app.py and images into the container
COPY --chown=user:user . $HOME/app

# 7. Launch Streamlit safely with CORS disabled so Hugging Face doesn't hang
CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0", "--server.enableCORS", "false", "--server.enableXsrfProtection", "false"]