kadabengaran commited on
Commit
57482e4
1 Parent(s): 9cb1c42

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +52 -0
Dockerfile ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
2
+
3
+ # Set ARG and ENV for non-interactive installations and Python unbuffered mode
4
+ ARG DEBIAN_FRONTEND=noninteractive
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ # Install essential system packages
8
+ RUN apt-get update && apt-get install --no-install-recommends -y \
9
+ build-essential \
10
+ python3.8 \
11
+ python3.8-venv \
12
+ python3-pip \
13
+ git \
14
+ ffmpeg \
15
+ libglib2.0-0 \
16
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Set the working directory
19
+ WORKDIR /code
20
+
21
+ # Copy requirements and install them
22
+ COPY ./requirements.txt /code/requirements.txt
23
+
24
+ # Create a non-root user and switch to it
25
+ RUN useradd -m -u 1000 user
26
+ USER user
27
+
28
+ # Set environment variables for the user
29
+ ENV HOME=/home/user \
30
+ PATH=/home/user/.local/bin:$PATH \
31
+ PYTHONPATH=$HOME/app \
32
+ PYTHONUNBUFFERED=1 \
33
+ GRADIO_ALLOW_FLAGGING=never \
34
+ GRADIO_NUM_PORTS=1 \
35
+ GRADIO_SERVER_NAME=0.0.0.0 \
36
+ GRADIO_THEME=huggingface
37
+
38
+ # Install Python dependencies
39
+ RUN pip3 install --no-cache-dir --upgrade pip && \
40
+ pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
41
+
42
+ # Set the application directory for the user
43
+ WORKDIR $HOME/app
44
+
45
+ # Copy the application code to the container
46
+ COPY --chown=user . $HOME/app
47
+
48
+ # Expose the Uvicorn FastAPI port
49
+ EXPOSE 7860
50
+
51
+ # Run the application using the same command as local setup
52
+ CMD ["python3.8", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]