gtech13 commited on
Commit
946ab5d
·
verified ·
1 Parent(s): b95f154

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -11
Dockerfile CHANGED
@@ -1,19 +1,27 @@
1
  FROM python:3.10
2
 
3
- # 1. Create the specific user required by Hugging Face Spaces
 
 
 
 
 
 
 
4
  RUN useradd -m -u 1000 user
 
 
5
  USER user
6
- ENV PATH="/home/user/.local/bin:$PATH"
7
 
8
- # 2. Set the working directory to that user's safe space
9
- WORKDIR /home/user/app
 
10
 
11
- # 3. Copy requirements and install them securely
12
- COPY --chown=user:user requirements.txt .
13
- RUN pip install --user --no-cache-dir -r requirements.txt
14
 
15
- # 4. Copy your app.py and images into the safe space
16
- COPY --chown=user:user . .
17
 
18
- # 5. Launch using the Python Module bypass (The Fix!)
19
- CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
 
1
  FROM python:3.10
2
 
3
+ # 1. Set a temporary working directory
4
+ WORKDIR /code
5
+
6
+ # 2. Copy just the requirements first and install them GLOBALLY
7
+ COPY ./requirements.txt /code/requirements.txt
8
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9
+
10
+ # 3. Create the restricted user required by Hugging Face Spaces
11
  RUN useradd -m -u 1000 user
12
+
13
+ # 4. Switch to that user
14
  USER user
 
15
 
16
+ # 5. Set up the user's safe environment variables
17
+ ENV HOME=/home/user
18
+ ENV PATH=/home/user/.local/bin:$PATH
19
 
20
+ # 6. Set the working directory to the user's safe space
21
+ WORKDIR $HOME/app
 
22
 
23
+ # 7. Copy your app.py and images into the container, owned by the safe user
24
+ COPY --chown=user:user . $HOME/app
25
 
26
+ # 8. Launch Streamlit safely
27
+ CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]