File size: 1,101 Bytes
d04c875
 
eb6c83d
d04c875
eb6c83d
 
bbcb202
 
2886988
 
bbcb202
2886988
 
bbcb202
eb6c83d
 
bbcb202
d04c875
 
 
 
 
 
 
 
eb6c83d
bbcb202
d04c875
eb6c83d
bbcb202
2886988
 
bbcb202
2886988
f3fc06a
bbcb202
eb6c83d
 
d04c875
 
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
# Use an official Python runtime as the base image
FROM python:3.11-slim

# Set working directory inside the container
WORKDIR /app

# Create a non-root user to match Hugging Face Spaces' setup
# UID 1000 is commonly used in Spaces, but this may vary
RUN useradd -m -u 1000 appuser

# Create the saved_models directory and set ownership to appuser
RUN mkdir -p /app/saved_models && chown -R appuser:appuser /app

# Copy requirements.txt to the working directory
COPY requirements.txt .

# Install system dependencies (for faiss, torch, etc.)
RUN apt-get update && apt-get install -y \
    build-essential \
    libatlas-base-dev \
    gfortran \
    && rm -rf /var/lib/apt/lists/*

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

# Copy the entire application code and datasets to the container
COPY . .

# Set ownership of all files to appuser
RUN chown -R appuser:appuser /app

# Switch to the non-root user
USER appuser

# Expose the port your Flask app will run on (7860 as specified in app.py)
EXPOSE 7860

# Command to run the Flask app
CMD ["python", "app.py"]