Vighnesh-Tiwarekar commited on
Commit
dfb2da3
·
1 Parent(s): fb2568b

Fix version 6

Browse files
Files changed (2) hide show
  1. Dockerfile +15 -12
  2. app.py +2 -2
Dockerfile CHANGED
@@ -1,21 +1,24 @@
1
- # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory in the container
5
  WORKDIR /code
6
 
7
- # Copy the requirements file into the container
8
- COPY ./requirements.txt /code/requirements.txt
9
 
10
- # Install the dependencies
11
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
12
 
13
- # Download the required NLTK data to match code path
14
- RUN python -m nltk.downloader -d /usr/local/nltk_data wordnet omw-1.4
15
 
 
 
 
16
 
17
- # Copy the rest of the application code
18
- COPY . /code/
19
 
20
- # Command to run the application
21
- CMD ["python", "app.py"]
 
 
1
  FROM python:3.9-slim
2
 
3
+ # Set working directory
4
  WORKDIR /code
5
 
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*
8
 
9
+ # Copy and install Python dependencies
10
+ COPY requirements.txt .
11
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
12
 
13
+ # Set NLTK data path
14
+ ENV NLTK_DATA=/usr/local/nltk_data
15
 
16
+ # Download NLTK data to the correct location
17
+ RUN mkdir -p $NLTK_DATA && \
18
+ python -m nltk.downloader -d $NLTK_DATA wordnet omw-1.4
19
 
20
+ # Copy source code
21
+ COPY . .
22
 
23
+ # Run app
24
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import os
2
- os.environ["NLTK_DATA"] = "/usr/local/nltk_data"
3
 
4
  import spacy
5
  from nltk.corpus import wordnet as wn
6
  from nltk.stem import WordNetLemmatizer
7
  import nltk
8
  from flask import Flask, request, jsonify
9
-
10
  # Ensure NLTK corpora are available
11
  try:
12
  nltk.data.find('corpora/wordnet')
 
1
  import os
2
+
3
 
4
  import spacy
5
  from nltk.corpus import wordnet as wn
6
  from nltk.stem import WordNetLemmatizer
7
  import nltk
8
  from flask import Flask, request, jsonify
9
+ os.environ["NLTK_DATA"] = "/usr/local/nltk_data"
10
  # Ensure NLTK corpora are available
11
  try:
12
  nltk.data.find('corpora/wordnet')