File size: 964 Bytes
38e9983
 
5b0cf88
2d4c3ce
 
5b0cf88
2d4c3ce
 
5b0cf88
2d4c3ce
 
5b0cf88
38e9983
2d4c3ce
65b763e
2d4c3ce
 
5120110
2d4c3ce
 
5120110
2d4c3ce
 
 
 
 
 
 
 
 
 
 
5b0cf88
 
38e9983
 
 
2d4c3ce
38e9983
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 Python 3.9 as base image
FROM python:3.9

# Set working directory within the container
WORKDIR /code

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

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

# Install ffmpeg (if needed)
RUN apt update && apt install -y ffmpeg

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

# Switch to the non-root user
USER user

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory for the application
WORKDIR $HOME/app

# Copy the application code to the working directory
COPY --chown=user . $HOME/app

# Expose port 7860 (assuming your FastAPI app runs on this port)
EXPOSE 7860

# Ensure PyTorch is installed
RUN pip install torch torchvision torchaudio

# Command to run the FastAPI application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]