Bikas0's picture
Docker
faa4c32 verified
raw
history blame
1.05 kB
# Use the official Python image from the Docker Hub
FROM python:3.10.0-slim-buster
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Upgrade pip to the latest version
RUN pip install --upgrade pip
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Create directories for NLTK and Hugging Face cache data
RUN mkdir -p /app/nltk_data /app/.cache/huggingface /app/.huggingface_cache
# Download NLTK data (punkt)
RUN python -m nltk.downloader -d /app/nltk_data punkt
# Set environment variables
ENV NLTK_DATA=/app/nltk_data
ENV HF_HOME=/app/.huggingface_cache
# Change ownership of directories to the non-root user
RUN chown -R nobody:nogroup /app/nltk_data /app/.huggingface_cache /app
# Switch to a non-root user
USER nobody
# Make port 7860 available to the world outside this container
EXPOSE 7860
# Command to run the application
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "app:app"]