iamspruce commited on
Commit
d893801
·
1 Parent(s): ce2ce69

download wordnet

Browse files
Files changed (1) hide show
  1. Dockerfile +21 -3
Dockerfile CHANGED
@@ -3,21 +3,38 @@ FROM python:3.10-slim
3
  WORKDIR /app
4
 
5
  # Install system dependencies
 
 
6
  RUN apt-get update && apt-get install -y git && \
7
  rm -rf /var/lib/apt/lists/*
8
 
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
12
-
 
13
  RUN python -m spacy download en_core_web_sm
14
 
 
 
 
15
 
 
 
 
 
16
  ENV HF_HOME=/cache
17
- RUN mkdir -p /cache && chmod -R 777 /cache
 
18
 
 
 
 
19
 
20
- RUN mkdir -p /.cache && chmod -R 777 /.cache
 
 
 
21
 
22
 
23
  COPY app ./app
@@ -25,4 +42,5 @@ COPY app ./app
25
  # Expose the port your FastAPI application will run on
26
  EXPOSE 7860
27
 
 
28
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
 
3
  WORKDIR /app
4
 
5
  # Install system dependencies
6
+ # git might not be strictly necessary for deployment unless you're cloning repos at runtime
7
+ # but it's often useful for debugging or specific workflows.
8
  RUN apt-get update && apt-get install -y git && \
9
  rm -rf /var/lib/apt/lists/*
10
 
11
  COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # --- Install spaCy model ---
15
+ # This downloads the small English model
16
  RUN python -m spacy download en_core_web_sm
17
 
18
+ # --- Install NLTK WordNet data ---
19
+ # This downloads the WordNet corpus for NLTK
20
+ RUN python -m nltk.downloader wordnet
21
 
22
+ # --- Configure cache directories for Hugging Face models ---
23
+ # HF_HOME is where SentenceTransformers and other Hugging Face models will cache.
24
+ # /.cache is also a common location many libraries default to if HF_HOME isn't set,
25
+ # or for other internal caching. Setting permissions ensures the app can write there.
26
  ENV HF_HOME=/cache
27
+ ENV TRANSFORMERS_CACHE=/cache
28
+ ENV NLTK_DATA=/nltk_data
29
 
30
+ # Create directories and set appropriate permissions
31
+ RUN mkdir -p /cache && chmod -R 777 /cache
32
+ RUN mkdir -p /root/.cache && chmod -R 777 /root/.cache
33
 
34
+ # Ensure NLTK uses the specified data path.
35
+ # This makes subsequent 'nltk.downloader' calls store data here,
36
+ # and NLTK will look here first.
37
+ RUN python -c "import nltk; nltk.data.path.append('/nltk_data')"
38
 
39
 
40
  COPY app ./app
 
42
  # Expose the port your FastAPI application will run on
43
  EXPOSE 7860
44
 
45
+ # Command to run your FastAPI application
46
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]