diamond-in commited on
Commit
4e8855e
·
verified ·
1 Parent(s): 7ffd2ce

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,26 +1,35 @@
1
  FROM python:3.9-slim
2
 
3
- # 1. Install proot for "fake root"
 
4
  RUN apt-get update && apt-get install -y \
5
- proot \
6
  curl \
 
 
 
7
  && rm -rf /var/lib/apt/lists/*
8
 
9
- # 2. Setup User (Hugging Face runs as user 1000)
10
  RUN useradd -m -u 1000 user
 
 
 
 
 
 
11
  USER user
12
  ENV HOME=/home/user \
13
  PATH=/home/user/.local/bin:$PATH
14
 
15
- # 3. Setup Working Directory
16
  WORKDIR /home/user/app
17
 
18
- # 4. Install Dependencies
19
  COPY --chown=user requirements.txt .
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
- # 5. Copy Application Code
23
  COPY --chown=user . .
24
 
25
- # 6. Start FastAPI (Looking for app.py)
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9-slim
2
 
3
+ # 1. Install sudo and basic system tools
4
+ # We do this as actual root during the build process
5
  RUN apt-get update && apt-get install -y \
6
+ sudo \
7
  curl \
8
+ wget \
9
+ git \
10
+ procps \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
+ # 2. Setup the Hugging Face user (ID 1000)
14
  RUN useradd -m -u 1000 user
15
+
16
+ # 3. THE MAGIC SAUCE: Grant Real Root permissions
17
+ # This line adds 'user' to sudoers and disables the password requirement
18
+ RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
19
+
20
+ # 4. Set up environment
21
  USER user
22
  ENV HOME=/home/user \
23
  PATH=/home/user/.local/bin:$PATH
24
 
 
25
  WORKDIR /home/user/app
26
 
27
+ # 5. Install Python Dependencies
28
  COPY --chown=user requirements.txt .
29
  RUN pip install --no-cache-dir -r requirements.txt
30
 
31
+ # 6. Copy App
32
  COPY --chown=user . .
33
 
34
+ # 7. Run FastAPI
35
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]