GopalKrushnaMahapatra commited on
Commit
281236f
·
verified ·
1 Parent(s): 2152439

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -24
Dockerfile CHANGED
@@ -1,57 +1,51 @@
1
- # Use Python 3.10
2
- FROM python:3.10-slim
3
 
4
- # 1. Install System Tools (Git, Java, Wget)
5
- # Java is required for LanguageTool
6
  RUN apt-get update && \
7
  apt-get install -y \
8
  git \
9
  wget \
10
- openjdk-21-jre-headless \
11
  build-essential \
12
  python3-dev \
13
  gcc \
14
  && apt-get clean
15
 
16
- # Set Java Home
17
- ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
18
 
19
- # 2. Set working directory
20
  WORKDIR /app
21
 
22
- # 3. Setup Cache Folders (Prevents Permission Errors)
23
  ENV XDG_CACHE_HOME=/app/cache
24
  ENV TRANSFORMERS_CACHE=/app/cache
25
  ENV HF_HOME=/app/cache
26
  RUN mkdir -p /app/cache && chmod 777 /app/cache
27
 
28
- # 4. Install Dependencies
29
  COPY requirements.txt .
30
  RUN pip install --no-cache-dir --upgrade pip && \
31
  pip install --no-cache-dir -r requirements.txt
32
 
33
- # 5. INSTALL GECToR LIBRARY
34
- # We clone the library code so python can "import gector"
35
  RUN git clone https://github.com/gotutiyan/gector.git /app/gector_lib
 
36
  RUN pip install --no-cache-dir /app/gector_lib
37
 
38
- # 6. SETUP DATA & MODEL
39
  RUN mkdir -p /app/data
40
 
41
- # A. DOWNLOAD MODEL WEIGHTS (Heavy file - 500MB)
42
- # We download this here so you don't have to upload it to Git
43
  RUN wget -O /app/data/gector_model.th https://huggingface.co/gotutiyan/gector-roberta-base-5k/resolve/main/pytorch_model.bin
44
 
45
- # B. MOVE YOUR UPLOADED VOCAB FILE
46
- # COPY . . (in step 7) will bring 'verb-form-vocab.txt' to /app/
47
- # We will move it to /app/data/ after copying, or just point the code to it.
48
-
49
- # 7. Copy Your App Code (Includes verb-form-vocab.txt)
50
  COPY . .
51
 
52
- # 8. Move the vocab file to the expected folder (Optional but clean)
53
- # Assuming you uploaded it to the root of your Space
54
- RUN mv verb-form-vocab.txt /app/data/verb-form-vocab.txt || echo "File not found in root, skipping move"
55
 
56
- # 9. Run App
57
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # 1. UPGRADE to Python 3.11 (Required by GECToR)
2
+ FROM python:3.11-slim
3
 
4
+ # 2. Install System Tools
5
+ # We switch back to openjdk-17 because it is the standard for Python 3.11 images
6
  RUN apt-get update && \
7
  apt-get install -y \
8
  git \
9
  wget \
10
+ openjdk-17-jre-headless \
11
  build-essential \
12
  python3-dev \
13
  gcc \
14
  && apt-get clean
15
 
16
+ # Set Java Home (Updated for Java 17)
17
+ ENV JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
18
 
19
+ # 3. Set working directory
20
  WORKDIR /app
21
 
22
+ # 4. Setup Cache Folders
23
  ENV XDG_CACHE_HOME=/app/cache
24
  ENV TRANSFORMERS_CACHE=/app/cache
25
  ENV HF_HOME=/app/cache
26
  RUN mkdir -p /app/cache && chmod 777 /app/cache
27
 
28
+ # 5. Install Dependencies
29
  COPY requirements.txt .
30
  RUN pip install --no-cache-dir --upgrade pip && \
31
  pip install --no-cache-dir -r requirements.txt
32
 
33
+ # 6. INSTALL GECToR LIBRARY
 
34
  RUN git clone https://github.com/gotutiyan/gector.git /app/gector_lib
35
+ # This step failed before; now it will pass because we have Python 3.11
36
  RUN pip install --no-cache-dir /app/gector_lib
37
 
38
+ # 7. SETUP DATA & MODEL
39
  RUN mkdir -p /app/data
40
 
41
+ # Download Model Weights
 
42
  RUN wget -O /app/data/gector_model.th https://huggingface.co/gotutiyan/gector-roberta-base-5k/resolve/main/pytorch_model.bin
43
 
44
+ # 8. Copy App Code
 
 
 
 
45
  COPY . .
46
 
47
+ # 9. Move vocab file if needed (ensure it exists)
48
+ RUN mv verb-form-vocab.txt /app/data/verb-form-vocab.txt || echo "File not found root, skipping move"
 
49
 
50
+ # 10. Run App
51
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]