YazeedBinShihah commited on
Commit
1a32ee7
·
verified ·
1 Parent(s): fc31e1e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -29
Dockerfile CHANGED
@@ -1,29 +1,32 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.11-slim
3
-
4
- # Set the working directory in the container
5
- WORKDIR /app
6
-
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- build-essential \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- # Copy the requirements file into the container
13
- COPY requirements.txt .
14
-
15
- # Install any needed packages specified in requirements.txt
16
- RUN pip install --no-cache-dir -r requirements.txt
17
-
18
- # Copy the rest of the application code into the container
19
- COPY . .
20
-
21
- # Exposure port for Gradio
22
- EXPOSE 7860
23
-
24
- # Define environment variables (optional, can be overridden by HF)
25
- ENV GRADIO_SERVER_NAME="0.0.0.0"
26
- ENV GRADIO_SERVER_PORT=7860
27
-
28
- # Run the application
29
- CMD ["python", "app.py"]
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.12-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Create a non-root user for security and HF compatibility
13
+ RUN useradd -m -u 1000 user
14
+ USER user
15
+ ENV PATH="/home/user/.local/bin:${PATH}"
16
+
17
+ # Copy requirements first for better caching
18
+ COPY --chown=user requirements.txt .
19
+ RUN pip install --no-cache-dir --user -r requirements.txt
20
+
21
+ # Copy the rest of the application
22
+ COPY --chown=user . .
23
+
24
+ # Gradio Environment Variables
25
+ ENV GRADIO_SERVER_NAME="0.0.0.0" \
26
+ GRADIO_SERVER_PORT=7860 \
27
+ PYTHONUNBUFFERED=1
28
+
29
+ EXPOSE 7860
30
+
31
+ # Run the application
32
+ CMD ["python", "app.py"]