GopalKrushnaMahapatra commited on
Commit
010f22b
·
verified ·
1 Parent(s): 5c8c123

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -5
Dockerfile CHANGED
@@ -1,9 +1,12 @@
1
  # Use Python 3.10
2
  FROM python:3.10-slim
3
 
4
- # 1. Install Java 21 (Required for LanguageTool) and Build Tools
 
5
  RUN apt-get update && \
6
  apt-get install -y \
 
 
7
  openjdk-21-jre-headless \
8
  build-essential \
9
  python3-dev \
@@ -16,19 +19,39 @@ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
16
  # 2. Set working directory
17
  WORKDIR /app
18
 
19
- # 3. SET WRITABLE CACHE FOLDERS (Fixes Runtime Error)
20
  ENV XDG_CACHE_HOME=/app/cache
21
  ENV TRANSFORMERS_CACHE=/app/cache
22
  ENV HF_HOME=/app/cache
23
  RUN mkdir -p /app/cache && chmod 777 /app/cache
24
 
25
- # 4. Install dependencies
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir --upgrade pip && \
28
  pip install --no-cache-dir -r requirements.txt
29
 
30
- # 5. Copy app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  COPY . .
32
 
33
- # 6. Run app
 
 
 
 
34
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
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 \
 
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"]