File size: 1,112 Bytes
faa4c32
0d64ea6
 
 
 
 
 
 
 
627a1e0
 
 
c32b3bf
 
 
faa4c32
c606ee0
53b96bd
e79c88b
208e09a
c32b3bf
c606ee0
0d64ea6
53b96bd
d43031c
0d64ea6
0a4189b
faa4c32
0a4189b
 
 
 
0d64ea6
627a1e0
0d64ea6
 
627a1e0
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 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 and wordnet)
RUN python -m nltk.downloader -d /app/nltk_data punkt wordnet

# Set environment variables
ENV NLTK_DATA=/app/nltk_data
ENV HF_HOME=/app/.huggingface_cache
ENV TRANSFORMERS_CACHE=/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"]