abdoolamunir's picture
Update Dockerfile
021525a verified
# 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