File size: 1,152 Bytes
91a9877
 
15b7ca5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91a9877
 
 
15b7ca5
 
 
 
 
 
 
 
 
 
 
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 standard Python base image
FROM python:3.9-slim

# Set environment variables to non-interactive
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary packages
RUN apt-get update && \
    apt-get install -y \
        python3 \
        python3-pip \
        python3-venv \
        wget \
        git \
        && rm -rf /var/lib/apt/lists/*

# Set up a user with ID 1000 as required by Hugging Face
RUN useradd -m -u 1000 user
WORKDIR /home/user/app
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Create and activate a virtual environment
RUN python3 -m venv /home/user/venv
ENV PATH="/home/user/venv/bin:$PATH"

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

# Add a comment about installing CPU-only dependencies here if needed for the full application
# e.g., RUN pip install torch==1.x.x+cpu torchvision==0.x.x+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html

# Copy application files
COPY --chown=user app.py .

# Switch to the user
USER user

# Expose port for the web server
EXPOSE 7860

# Run the application
CMD ["python3", "app.py"]