akborana4 commited on
Commit
139a430
·
verified ·
1 Parent(s): 690dd7e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -15
Dockerfile CHANGED
@@ -1,25 +1,54 @@
1
- # Use a lightweight Python base image
2
- FROM python:3.11-slim
3
 
4
- WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- # Install dependencies
7
- COPY requirements.txt .
8
- RUN pip install --no-cache-dir -r requirements.txt
9
 
10
- # Create a non-root user (Required for Hugging Face Spaces)
11
- RUN useradd -m -u 1000 user
12
- USER user
13
  ENV HOME=/home/user \
14
- PATH=/home/user/.local/bin:$PATH
 
15
 
16
  WORKDIR $HOME/app
17
 
18
- # Copy the application code
19
- COPY --chown=user . $HOME/app
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- # Hugging Face routes traffic to port 7860
22
  EXPOSE 7860
23
 
24
- # Run the FastAPI server via Uvicorn
25
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a full Ubuntu base for a complete, unrestricted Linux environment
2
+ FROM ubuntu:22.04
3
 
4
+ # 1. Install System Dependencies (curl, git, build-essential, nano, htop, etc.)
5
+ USER root
6
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
7
+ python3 \
8
+ python3-pip \
9
+ python3-venv \
10
+ curl \
11
+ git \
12
+ sudo \
13
+ wget \
14
+ nano \
15
+ htop \
16
+ build-essential \
17
+ libssl-dev \
18
+ libffi-dev \
19
+ && apt-get clean \
20
+ && rm -rf /var/lib/apt/lists/*
21
 
22
+ # 2. Create non-root user and grant passwordless SUDO (No Restrictions!)
23
+ RUN adduser --disabled-password --gecos '' user \
24
+ && echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
25
 
26
+ RUN mkdir -p /home/user/app && chown -R user:user /home/user/app
27
+
28
+ # Set environment variables
29
  ENV HOME=/home/user \
30
+ PATH=/home/user/.local/bin:$PATH \
31
+ PYTHONUNBUFFERED=1
32
 
33
  WORKDIR $HOME/app
34
 
35
+ # 3. Setup Python Environment
36
+ USER user
37
+ RUN python3 -m pip install --upgrade pip
38
+
39
+ # 4. Copy Files and Set Permissions
40
+ COPY --chown=user:user . .
41
+
42
+ # 5. Install Python Requirements
43
+ RUN pip3 install --no-cache-dir -r requirements.txt
44
+
45
+ # 6. Create Persistent Directories inside WORKDIR
46
+ RUN mkdir -p sessions downloads && chmod -R 777 sessions downloads
47
+
48
+ # 7. Final Script Setup
49
+ RUN chmod +x start.sh
50
 
51
+ # Hugging Face Spaces port
52
  EXPOSE 7860
53
 
54
+ ENTRYPOINT ["./start.sh"]