File size: 808 Bytes
30b75f2
 
8f8764f
 
 
 
 
 
 
 
 
 
 
14350c4
 
 
 
 
 
 
 
8f8764f
30b75f2
8f8764f
 
30b75f2
14350c4
 
 
 
30b75f2
8f8764f
 
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
FROM python:3.9

# Install system dependencies for OpenCV
RUN apt-get update && apt-get install -y \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libsm6 \
    libxrender1 \
    libxext6 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /code

# Create a non-root user to run the application
RUN useradd -m appuser

# Create directories with appropriate permissions
RUN mkdir -p /code/output && \
    chown -R appuser:appuser /code

COPY --chown=appuser:appuser ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# For headless matplotlib
ENV MPLBACKEND=Agg

COPY --chown=appuser:appuser . /code/

# Switch to the non-root user
USER appuser

# Make sure the app.py file is correctly named
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]