Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +20 -3
Dockerfile
CHANGED
|
@@ -1,49 +1,66 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
|
|
|
| 3 |
# Install required system dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
git curl build-essential cmake \
|
| 6 |
&& rm -rf /var/lib/apt/lists/*
|
| 7 |
|
|
|
|
| 8 |
# Set working directory
|
| 9 |
WORKDIR /app
|
| 10 |
|
|
|
|
| 11 |
# Create writable directories
|
| 12 |
RUN mkdir -p /app/.cache /app/vector_database && chmod -R 777 /app
|
| 13 |
|
|
|
|
| 14 |
# Set environment variables
|
| 15 |
ENV TRANSFORMERS_CACHE=/app/.cache \
|
| 16 |
HF_HOME=/app/.cache \
|
| 17 |
CHROMADB_DISABLE_TELEMETRY=true
|
| 18 |
|
|
|
|
| 19 |
# Install dependencies from requirements.txt first
|
| 20 |
COPY requirements.txt .
|
| 21 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 22 |
|
|
|
|
| 23 |
# Install nltk and download punkt tokenizer once during build
|
| 24 |
RUN python -m nltk.downloader punkt punkt_tab
|
| 25 |
|
|
|
|
| 26 |
# β
STEP 1: Copy the source data and the Python script into the image
|
| 27 |
COPY ./combined_context.jsonl .
|
| 28 |
COPY ./create_granular_chunks.py .
|
| 29 |
|
|
|
|
| 30 |
# β
STEP 2: Run the script to generate the chunks file inside the image
|
| 31 |
RUN python create_granular_chunks.py
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
# Note: As recommended before, 'llama-cpp-python' should be removed from requirements.txt
|
| 34 |
# to rely on the more stable, version-pinned installation below.
|
| 35 |
RUN pip install --no-cache-dir llama-cpp-python==0.2.61
|
| 36 |
|
| 37 |
-
|
|
|
|
| 38 |
COPY ./app ./app
|
| 39 |
|
|
|
|
| 40 |
# Download your fine-tuned TinyLlama GGUF model
|
| 41 |
RUN curl -fL -o /app/tinyllama_dop_q4_k_m.gguf \
|
| 42 |
https://huggingface.co/Kalpokoch/FinetunedQuantizedTinyLama/resolve/main/tinyllama_dop_q4_k_m.gguf \
|
| 43 |
&& echo "β
TinyLlama model downloaded."
|
| 44 |
|
|
|
|
| 45 |
# Expose the application port
|
| 46 |
EXPOSE 7860
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
|
| 4 |
# Install required system dependencies
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
git curl build-essential cmake \
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
+
|
| 10 |
# Set working directory
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
+
|
| 14 |
# Create writable directories
|
| 15 |
RUN mkdir -p /app/.cache /app/vector_database && chmod -R 777 /app
|
| 16 |
|
| 17 |
+
|
| 18 |
# Set environment variables
|
| 19 |
ENV TRANSFORMERS_CACHE=/app/.cache \
|
| 20 |
HF_HOME=/app/.cache \
|
| 21 |
CHROMADB_DISABLE_TELEMETRY=true
|
| 22 |
|
| 23 |
+
|
| 24 |
# Install dependencies from requirements.txt first
|
| 25 |
COPY requirements.txt .
|
| 26 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 27 |
|
| 28 |
+
|
| 29 |
# Install nltk and download punkt tokenizer once during build
|
| 30 |
RUN python -m nltk.downloader punkt punkt_tab
|
| 31 |
|
| 32 |
+
|
| 33 |
# β
STEP 1: Copy the source data and the Python script into the image
|
| 34 |
COPY ./combined_context.jsonl .
|
| 35 |
COPY ./create_granular_chunks.py .
|
| 36 |
|
| 37 |
+
|
| 38 |
# β
STEP 2: Run the script to generate the chunks file inside the image
|
| 39 |
RUN python create_granular_chunks.py
|
| 40 |
|
| 41 |
+
|
| 42 |
+
# β
STEP 3: The 'granular_chunks_improved.jsonl' now exists inside the image.
|
| 43 |
+
# We no longer need to copy it from our local machine.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
# Note: As recommended before, 'llama-cpp-python' should be removed from requirements.txt
|
| 47 |
# to rely on the more stable, version-pinned installation below.
|
| 48 |
RUN pip install --no-cache-dir llama-cpp-python==0.2.61
|
| 49 |
|
| 50 |
+
|
| 51 |
+
# Copy the rest of the application code
|
| 52 |
COPY ./app ./app
|
| 53 |
|
| 54 |
+
|
| 55 |
# Download your fine-tuned TinyLlama GGUF model
|
| 56 |
RUN curl -fL -o /app/tinyllama_dop_q4_k_m.gguf \
|
| 57 |
https://huggingface.co/Kalpokoch/FinetunedQuantizedTinyLama/resolve/main/tinyllama_dop_q4_k_m.gguf \
|
| 58 |
&& echo "β
TinyLlama model downloaded."
|
| 59 |
|
| 60 |
+
|
| 61 |
# Expose the application port
|
| 62 |
EXPOSE 7860
|
| 63 |
|
| 64 |
+
|
| 65 |
+
# Run the FastAPI application
|
| 66 |
+
CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "7860"]
|