File size: 1,083 Bytes
3c078e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08c5d2f
 
 
 
021525a
 
 
 
 
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
# Use an official Python runtime as a parent image
FROM python:3.8-slim

# Set the working directory in the container
WORKDIR /app

# Copy only the files needed for pip install first to leverage Docker caching
COPY requirements.txt ./

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Install PyTorch
RUN pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/torch_stable.html


# Copy the rest of your application's source code from your host to your image filesystem
COPY . /app

# Make port 8000 available to the world outside this container
EXPOSE 8000

# Define environment variable
ENV NAME World

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

# Set environment variable for Transformers cache directory
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
# Create the directory for the Transformers cache
RUN mkdir -p /app/.cache/huggingface/transformers
# Give write permissions (if necessary)
RUN chmod -R 777 /app/.cache