chualinwei3 commited on
Commit
98db725
·
verified ·
1 Parent(s): 98cc1aa

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +56 -54
Dockerfile CHANGED
@@ -1,54 +1,56 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.10-slim
3
-
4
- # Set environment variables
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
- ENV PORT 7860
8
-
9
- # Install system dependencies for OpenCV and face_recognition
10
- RUN apt-get update && apt-get install -y \
11
- build-essential \
12
- cmake \
13
- libopenblas-dev \
14
- liblapack-dev \
15
- libx11-dev \
16
- libgtk-3-dev \
17
- libboost-python-dev \
18
- python3-dev \
19
- libgl1-mesa-glx \
20
- libglib2.0-0 \
21
- && apt-get clean && rm -rf /var/lib/apt/lists/*
22
-
23
- # Set the working directory in the container
24
- WORKDIR /app
25
-
26
- # Copy the requirements file into the container
27
- COPY requirements.txt .
28
-
29
- # Install gunicorn for production
30
- RUN pip install --no-cache-dir gunicorn
31
-
32
- # Install any needed packages specified in requirements.txt
33
- RUN pip install --no-cache-dir -r requirements.txt
34
-
35
- # Copy the rest of the application code into the container
36
- COPY . .
37
-
38
- # Ensure upload directory exists and has permissions
39
- RUN mkdir -p uploads/face_encodings && chmod -R 777 uploads
40
-
41
- # Create a non-root user (Hugging Face requirement)
42
- RUN useradd -m -u 1000 user
43
- USER user
44
- ENV HOME=/home/user \
45
- PATH=/home/user/.local/bin:$PATH
46
-
47
- WORKDIR $HOME/app
48
- COPY --chown=user . $HOME/app
49
-
50
- # Expose the port the app runs on
51
- EXPOSE 7860
52
-
53
- # Define the command to run the application
54
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app", "--timeout", "120"]
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONDONTWRITEBYTECODE 1
6
+ ENV PYTHONUNBUFFERED 1
7
+ ENV PORT 7860
8
+
9
+ # Install system dependencies for OpenCV and face_recognition
10
+ RUN apt-get update && apt-get install -y \
11
+ build-essential \
12
+ cmake \
13
+ libopenblas-dev \
14
+ liblapack-dev \
15
+ libx11-dev \
16
+ libgtk-3-dev \
17
+ libboost-python-dev \
18
+ python3-dev \
19
+ libgl1 \
20
+ libglib2.0-0 \
21
+ libsm6 \
22
+ libxext6 \
23
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
24
+
25
+ # Set the working directory in the container
26
+ WORKDIR /app
27
+
28
+ # Copy the requirements file into the container
29
+ COPY requirements.txt .
30
+
31
+ # Install gunicorn for production
32
+ RUN pip install --no-cache-dir gunicorn
33
+
34
+ # Install any needed packages specified in requirements.txt
35
+ RUN pip install --no-cache-dir -r requirements.txt
36
+
37
+ # Copy the rest of the application code into the container
38
+ COPY . .
39
+
40
+ # Ensure upload directory exists and has permissions
41
+ RUN mkdir -p uploads/face_encodings && chmod -R 777 uploads
42
+
43
+ # Create a non-root user (Hugging Face requirement)
44
+ RUN useradd -m -u 1000 user
45
+ USER user
46
+ ENV HOME=/home/user \
47
+ PATH=/home/user/.local/bin:$PATH
48
+
49
+ WORKDIR $HOME/app
50
+ COPY --chown=user . $HOME/app
51
+
52
+ # Expose the port the app runs on
53
+ EXPOSE 7860
54
+
55
+ # Define the command to run the application
56
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app", "--timeout", "120"]