File size: 1,713 Bytes
31be093
 
 
 
 
dd5565f
31be093
 
 
 
dd5565f
31be093
 
 
dd5565f
31be093
 
 
 
 
 
 
 
52eac59
31be093
 
 
 
 
 
 
 
dd5565f
 
 
 
 
31be093
 
 
 
 
dd5565f
31be093
 
 
 
 
dd5565f
31be093
 
 
 
dd5565f
31be093
 
 
dd5565f
 
31be093
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM python:3.8-slim

# Set ARG and ENV for non-interactive installations and Python unbuffered mode
ARG DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1 \
    APP_HOME=/code

# Create and set permissions for the application directory
RUN mkdir -p $APP_HOME && \
    chown -R 1000:1000 $APP_HOME

# Install essential system packages and Python development tools
RUN apt-get update && \
    apt-get install --no-install-recommends -y \
        python3-venv \
        python3-dev \
        software-properties-common \
        pkg-config \
        libhdf5-dev \
        libhdf5-serial-dev \
        build-essential \
        git \
        ffmpeg \
        libglib2.0-0 && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR $APP_HOME

# Clone the repository
RUN git clone https://github.com/kadabengarann/face-verify-api.git $APP_HOME

# Create a non-root user and set ownership
RUN useradd -m -u 1000 user && \
    chown -R user:user $APP_HOME

# Switch to non-root user
USER user

# Set environment variables for the user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONPATH=$APP_HOME \
    GRADIO_ALLOW_FLAGGING=never \
    GRADIO_NUM_PORTS=1 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    GRADIO_THEME=huggingface

# Install Python dependencies
RUN python3.8 -m pip install --no-cache-dir --upgrade pip setuptools wheel && \
    python3.8 -m pip install --no-cache-dir -r requirements.txt && \
    python3.8 -m pip install --no-cache-dir uvicorn

# Expose the Uvicorn FastAPI port
EXPOSE 7860

# Start the application
CMD cd $APP_HOME && \
    git pull origin main && \
    python3.8 -m uvicorn app:app --host 0.0.0.0 --port 7860 --reload --log-level info