description / Dockerfile
parthgajera's picture
Upload Dockerfile
a9f33d0 verified
# # 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"]