File size: 820 Bytes
0b5e1b0
fa8cc7d
946ab5d
 
 
 
 
 
 
 
fa8cc7d
946ab5d
 
fa8cc7d
 
946ab5d
 
 
fa8cc7d
946ab5d
 
fa8cc7d
946ab5d
 
fa8cc7d
946ab5d
 
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
26
27
FROM python:3.10

# 1. Set a temporary working directory
WORKDIR /code

# 2. Copy just the requirements first and install them GLOBALLY
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

# 4. Switch to that user
USER user

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

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

# 7. Copy your app.py and images into the container, owned by the safe user
COPY --chown=user:user . $HOME/app

# 8. Launch Streamlit safely
CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]