File size: 980 Bytes
3f2a13f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94df088
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 an official lightweight Python image
FROM python:3.11-slim

# Create a non-root user that Hugging Face requires (User ID 1000)
RUN useradd -m -u 1000 user
USER user

# Set up the environment paths for the new user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory
WORKDIR $HOME/app

# Copy your requirements and install them
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy all your application code and models into the container
COPY --chown=user . .

# Switch to root temporarily to create the /tmp/ folders and grant open permissions
USER root
RUN mkdir -p /tmp/tag_and_trail_downloads /tmp/tag_and_trail_uploads && \
    chmod -R 777 /tmp/tag_and_trail_downloads /tmp/tag_and_trail_uploads

# Switch back to the safe user
USER user

# Expose Hugging Face's mandatory port
EXPOSE 7860

# Command to boot up your ML Brain
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]