File size: 857 Bytes
0d42798
 
67d6f5b
0d42798
 
 
 
 
67d6f5b
0d42798
 
67d6f5b
0d42798
67d6f5b
 
0d42798
 
 
 
 
67d6f5b
 
0d42798
 
 
 
888cb75
0d42798
 
 
 
67d6f5b
0d42798
9be3338
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
# Use a lightweight Python image
FROM python:3.10.12

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

# Create a non-root user
RUN useradd -m -u 1000 user

# Set up the working directory
WORKDIR /app

# Copy the requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the rest of the application
COPY . .

# Create and set permissions for the cache directory
RUN mkdir -p /.cache /app/.cache && \
    chown -R user:user /.cache /app/.cache && \
    chmod -R u+w,go-w /.cache /app/.cache

ENV TORCH_HOME=/app/.cache/torch

# Switch to the non-root user
USER user

# Run the application, including the migration step
CMD ["bash", "-c", "uvicorn main:app --host 0.0.0.0 --port 7860"]