File size: 1,110 Bytes
2fa269c
81fe8c1
 
1bef953
 
81fe8c1
2fa269c
1bef953
2fa269c
81fe8c1
c6e26f4
1bef953
 
81fe8c1
1bef953
 
81fe8c1
1bef953
 
 
c6e26f4
 
81fe8c1
2fa269c
 
 
 
 
1bef953
81fe8c1
 
2fa269c
 
 
 
1bef953
81fe8c1
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
# Use the PyTorch image as the base
FROM pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime

# Create a new user with user ID 1000
RUN useradd -m -u 1000 user

# Set environment variables
ENV HF_HOME=/home/user/cache
ENV PATH="/home/user/.local/bin:$PATH"

# Switch to the new user
USER user
WORKDIR /home/user/app

# Create the cache directory with correct ownership and permissions
RUN mkdir -p /home/user/cache && chmod -R 777 /home/user/cache

# Copy application files with ownership set to the new user
COPY --chown=user . /home/user/app

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

# Debugging: Check if uvicorn is installed and print its location
RUN which uvicorn || echo "uvicorn is not installed!"
RUN pip show uvicorn || echo "uvicorn package details not found!"
RUN echo $PATH

# Expose the application port
EXPOSE 7860

# Debugging: Print Python version and installed packages
RUN python --version
RUN pip list

# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]