File size: 1,264 Bytes
d18cfcb
 
 
583097f
b6f66bb
76d8957
f8b78df
b6f66bb
 
8e0a61f
 
b6f66bb
 
d18cfcb
7610381
d18cfcb
b0a5f82
beec292
b0a5f82
 
 
beec292
 
b0a5f82
 
 
f8b78df
b0a5f82
d18cfcb
a946a90
d18cfcb
 
f8b78df
7655a55
d18cfcb
 
 
 
583097f
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Use a lightweight official Python image as the base
FROM python:3.10-slim

# Install system-level dependencies for computer vision libraries
RUN apt-get update && apt-get install -y \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libfontconfig1 \
    libxrender1 \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
WORKDIR /app

# Create a non-root user and give them ownership of the working directory
RUN useradd -m -s /bin/bash appuser
RUN chown -R appuser:appuser /app

# Switch to the new user for all subsequent commands
USER appuser

# Set the DEEPFACE_HOME environment variable to a writable directory
ENV DEEPFACE_HOME=/app

# Copy the requirements file from the 'model' directory
COPY model/requirements.txt .

# Install Python dependencies, including gunicorn
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the 'model' directory's contents
COPY model/ .

# Expose the port where the Flask API will run
EXPOSE 7860

# Use ENTRYPOINT to make the container run as a specific executable
# This is more reliable than CMD for a consistent startup
ENTRYPOINT ["python3", "-m", "gunicorn"]

# Define the default arguments for the ENTRYPOINT
CMD ["--bind", "0.0.0.0:7860", "app:app"]