SharathReddy commited on
Commit
89ed536
·
verified ·
1 Parent(s): ffc40d5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -16
Dockerfile CHANGED
@@ -1,26 +1,36 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.10-slim
3
 
4
- # Set the working directory in the container
5
- WORKDIR /code
 
6
 
7
- # Set a writeable cache directory for Hugging Face models
8
- ENV HF_HOME /code/.cache
 
9
 
10
- # NEW: Install git into the container
11
- RUN apt-get update && apt-get install -y git
 
12
 
13
- # Copy the requirements file into the container
14
- COPY ./requirements.txt /code/requirements.txt
 
 
15
 
16
- # Install any needed packages specified in requirements.txt
17
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
18
 
19
- # Copy the rest of the application code into the container
20
- COPY ./app.py /code/app.py
21
 
22
- # Make port 7860 available to the world outside this container
 
 
 
23
  EXPOSE 7860
24
 
25
- # Run app.py when the container launches
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use a specific, stable version of the slim image
2
+ FROM python:3.10.13-slim-bullseye
3
 
4
+ # Set environment variables to prevent interactive prompts during build
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ ENV PYTHONUNBUFFERED=1
7
 
8
+ # Install git and other system dependencies as root
9
+ RUN apt-get update && apt-get install -y --no-install-recommends git curl && \
10
+ apt-get clean && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create a non-root user and its home directory
13
+ RUN useradd -m -u 1000 user
14
+ WORKDIR /home/user/code
15
 
16
+ # Set the cache directory for Hugging Face libraries
17
+ # This directory will be created with the correct ownership later
18
+ ENV HF_HOME=/home/user/code/.cache
19
+ ENV PATH="/home/user/.local/bin:${PATH}"
20
 
21
+ # Copy requirements file and install dependencies as the new user
22
+ # First, change ownership of the destination directory
23
+ RUN chown -R user:user /home/user/code
24
+ USER user
25
 
26
+ COPY --chown=user:user ./requirements.txt .
27
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
28
 
29
+ # Copy the rest of the application code
30
+ COPY --chown=user:user ./app.py .
31
+
32
+ # Expose the port
33
  EXPOSE 7860
34
 
35
+ # Run the application
36
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]