VatsalPatel18 commited on
Commit
200caa8
1 Parent(s): 21f7182

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -37
Dockerfile CHANGED
@@ -1,50 +1,33 @@
1
  # Use the official Python image as a base image
2
- FROM python:3.11-slim
3
-
4
- # Set environment variables
5
- ENV PYTHONUNBUFFERED=1 \
6
- PYTHONDONTWRITEBYTECODE=1 \
7
- GRADIO_SERVER_NAME="0.0.0.0" \
8
- REPO_ID="microsoft/Phi-3-mini-4k-instruct-gguf" \
9
- MODEL_FILE="Phi-3-mini-4k-instruct-q4.gguf"
10
-
11
- # Create a working directory
12
- WORKDIR /app
13
-
14
- # Install dependencies for building C++ extensions and SSL
15
- RUN apt-get update && \
16
- apt-get install -y --no-install-recommends \
17
- build-essential \
18
- cmake \
19
- openssl \
20
- wget \
21
- && apt-get clean \
22
- && rm -rf /var/lib/apt/lists/*
23
 
24
  # Copy the requirements file
25
- COPY requirements.txt /app/
26
 
27
  # Install Python dependencies
28
- RUN pip install --no-cache-dir -r requirements.txt
29
 
30
- # Copy SSL certificates
31
- COPY certificates /app/certificates
32
-
33
- # Copy the rest of the application code
34
- COPY . /app/
35
 
36
  # Create the cache directory with appropriate permissions
37
- RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
38
-
39
- # Ensure the model is downloaded
40
- RUN python download_model.py
41
 
42
  # Expose the port that Gradio will run on
43
  EXPOSE 7860
44
 
45
- # Set the user to root
46
- USER root
47
-
48
  # Run the application
49
- CMD ["python", "app.py"]
50
-
 
1
  # Use the official Python image as a base image
2
+ FROM python:3.9
3
+
4
+ # Set up a new user named "user" with user ID 1000
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the "user" user
8
+ USER user
9
+
10
+ # Set home to the user's home directory
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+
14
+ # Create working directory and set ownership to the user
15
+ WORKDIR $HOME/app
 
 
 
 
 
 
 
16
 
17
  # Copy the requirements file
18
+ COPY --chown=user ./requirements.txt $HOME/app/
19
 
20
  # Install Python dependencies
21
+ RUN pip install --no-cache-dir --upgrade -r $HOME/app/requirements.txt
22
 
23
+ # Copy the rest of the application code, setting the owner to the user
24
+ COPY --chown=user . $HOME/app/
 
 
 
25
 
26
  # Create the cache directory with appropriate permissions
27
+ RUN mkdir -p $HOME/app/hf_cache && chmod -R 777 $HOME/app/hf_cache
 
 
 
28
 
29
  # Expose the port that Gradio will run on
30
  EXPOSE 7860
31
 
 
 
 
32
  # Run the application
33
+ CMD ["python", "main.py"]