File size: 6,780 Bytes
a9f33d0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223


# # Use the official Python image

# FROM python:3.10-slim



# # Set environment variables

# ENV PYTHONDONTWRITEBYTECODE=1

# ENV PYTHONUNBUFFERED=1

# ENV TRANSFORMERS_CACHE=/data/huggingface/cache

# ENV HF_HOME=/app/.huggingface



# # Set the working directory

# WORKDIR /app



# # Install system dependencies

# RUN apt-get update && apt-get install -y \

#     git \

#     && rm -rf /var/lib/apt/lists/*



# # Create the Hugging Face cache directory and set proper permissions

# RUN mkdir -p /app/.huggingface && chmod -R 777 /app/.huggingface



# # Copy project files

# COPY . .



# # Install Python dependencies

# RUN pip install --no-cache-dir --upgrade pip \

#     && pip install --no-cache-dir -r requirements.txt



# # Expose the port FastAPI runs on

# EXPOSE 7860



# # Start the API using uvicorn

# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]






# # Use the official Python image

# FROM python:3.10-slim



# # Set environment variables

# ENV PYTHONDONTWRITEBYTECODE=1

# ENV PYTHONUNBUFFERED=1

# ENV HF_HOME=/app/.huggingface



# # Set the working directory

# WORKDIR /app



# # Install system dependencies

# RUN apt-get update && apt-get install -y \

#     git \

#     && rm -rf /var/lib/apt/lists/*



# # Create necessary directories and set permissions

# RUN mkdir -p /app/.huggingface /app/pegasus_model \

#     && chmod -R 777 /app/.huggingface /app/pegasus_model




# # Create necessary directories and set permissions

# RUN mkdir -p /app/.huggingface /app/pegasus_model /app/nltk_data \

#     && chmod -R 777 /app/.huggingface /app/pegasus_model /app/nltk_data



# ENV NLTK_DATA=/app/nltk_data




# # Copy project files

# COPY . .



# # Install Python dependencies

# RUN pip install --no-cache-dir --upgrade pip \

#     && pip install --no-cache-dir -r requirements.txt \

#     && pip install --no-cache-dir huggingface_hub



# # Download the Pegasus model and tokenizer

# RUN python3 -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='tuner007/pegasus_paraphrase', local_dir='/app/pegasus_model')"



# # Expose the port FastAPI runs on

# EXPOSE 7860



# # Start the API using uvicorn

# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]




##------------------------------------------------- add nltk------------------------------------------------




# # Use the official Python image

# FROM python:3.10-slim



# # Set environment variables

# ENV PYTHONDONTWRITEBYTECODE=1

# ENV PYTHONUNBUFFERED=1

# ENV HF_HOME=/app/.huggingface

# ENV NLTK_DATA=/app/nltk_data



# # Set the working directory

# WORKDIR /app



# # Install system dependencies

# RUN apt-get update && apt-get install -y \

#     git \

#     && rm -rf /var/lib/apt/lists/*



# # Create necessary directories and set permissions

# RUN mkdir -p /app/.huggingface /app/pegasus_model /app/nltk_data \

#     && chmod -R 777 /app/.huggingface /app/pegasus_model /app/nltk_data



# # Copy project files (excluding large model weights)

# COPY . .



# # Install Python dependencies

# RUN pip install --no-cache-dir --upgrade pip \

#     && pip install --no-cache-dir -r requirements.txt \

#     && pip install --no-cache-dir huggingface_hub



# # Download the Pegasus model and tokenizer from Hugging Face

# RUN python3 -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='tuner007/pegasus_paraphrase', local_dir='/app/pegasus_model')"



# # # Download NLTK 'punkt' tokenizer only

# # RUN python3 -m nltk.downloader punkt && cp -r /root/nltk_data/tokenizers /app/nltk_data/



# # Download NLTK 'punkt' tokenizer only (to correct path)

# RUN python3 -m nltk.downloader -d /app/nltk_data punkt

# ENV NLTK_DATA=/app/nltk_data





# # Expose the port FastAPI runs on

# EXPOSE 7860



# # Start the API using uvicorn

# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]




#######################################



# # Use the official Python image with slim variant

# FROM python:3.10-slim



# # Set environment variables

# ENV PYTHONDONTWRITEBYTECODE=1 \

#     PYTHONUNBUFFERED=1 \

#     HF_HOME=/app/.huggingface \

#     NLTK_DATA=/app/nltk_data \

#     PORT=7860 \

#     MAX_TOKENS=3500



# # Set the working directory

# WORKDIR /app



# # Install system dependencies

# RUN apt-get update && \

#     apt-get install -y --no-install-recommends git && \

#     rm -rf /var/lib/apt/lists/*



# # Create necessary directories with appropriate permissions

# RUN mkdir -p /app/.huggingface /app/pegasus_model /app/nltk_data && \

#     chmod -R 777 /app/.huggingface /app/pegasus_model /app/nltk_data



# # Install Python dependencies and NLTK data

# COPY requirements.txt .

# RUN pip install --no-cache-dir --upgrade pip && \

#     pip install --no-cache-dir -r requirements.txt && \

#     python -m nltk.downloader -d /app/nltk_data punkt punkt_tab averaged_perceptron_tagger && \

#     rm -rf /root/.cache/pip



# # Copy application code

# COPY . .



# # Download the Pegasus model

# RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='tuner007/pegasus_paraphrase', local_dir='/app/pegasus_model')"



# # Expose the port

# EXPOSE $PORT



# # Start the API

# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]




################### work ######################



# Use the official Python image with slim variant
FROM python:3.10-slim



# Set environment variables (fixed syntax)
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    HF_HOME=/app/.huggingface \
    NLTK_DATA=/app/nltk_data \
    PORT=7860 \
    OMP_NUM_THREADS=1 \
    TOKENIZERS_PARALLELISM=false



# Set the working directory
WORKDIR /app



# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends git && \
    rm -rf /var/lib/apt/lists/*



# Create necessary directories with appropriate permissions
RUN mkdir -p /app/.huggingface /app/pegasus_model /app/nltk_data && \
    chmod -R 777 /app/.huggingface /app/pegasus_model /app/nltk_data



# Install Python dependencies and NLTK data
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    python -m nltk.downloader -d /app/nltk_data punkt punkt_tab && \
    rm -rf /root/.cache/pip



# Copy application code
COPY . .



# Download the Pegasus model
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='tuner007/pegasus_paraphrase', local_dir='/app/pegasus_model')"



# Expose the port
EXPOSE $PORT



# Start the API
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]