File size: 1,604 Bytes
275ac6a
 
abc9746
275ac6a
abc9746
275ac6a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
abc9746
 
 
275ac6a
abc9746
 
275ac6a
abc9746
275ac6a
 
abc9746
 
 
275ac6a
abc9746
 
275ac6a
abc9746
 
 
275ac6a
abc9746
275ac6a
 
 
 
 
 
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
# # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
# # you will also find guides on how best to write your Dockerfile

# FROM python:3.9

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

# RUN useradd -m -u 1000 user
# USER user
# ENV PATH="/home/user/.local/bin:$PATH"

# WORKDIR /app

# COPY --chown=user ./requirements.txt requirements.txt
# RUN pip install --no-cache-dir --upgrade -r requirements.txt

# COPY --chown=user . /app
# CMD ["gunicorn", "-b", "0.0.0.0:7860","app:app"]




# Use the official Python image as the base image
FROM python:3.9-slim

# Install system dependencies for OpenCV and any other required libraries
RUN apt-get update && apt-get install -y \
    libgl1-mesa-glx \
    libglib2.0-0 \
    libx11-dev \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user and set permissions (safer and best practice)
RUN useradd -m -u 1000 user

# Switch to the non-root user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Set working directory
WORKDIR /app

# Copy requirements.txt and install Python dependencies
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of the application files to the container
COPY --chown=user . /app

# Expose the default port used by Hugging Face Spaces (usually 7860)
EXPOSE 7860

# Define the command to run the app (assuming you're using Gunicorn to run a web app)
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app"]