autogen / Dockerfile
tzintsunzu's picture
Create Dockerfile
c4539ec verified
FROM python:3.11-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install necessary packages
RUN apt-get update && apt-get install -y git
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Install additional dependencies
RUN pip install torch transformers diffusers gradio pandas tqdm accelerate
# Create writable cache directory and set permissions
RUN mkdir -p /app/cache && chmod -R 777 /app/cache
# Set environment variables for cache directories
ENV HF_HOME=/app/cache
ENV MPLCONFIGDIR=/app/cache/matplotlib
# Download models
RUN python -c "from transformers import AutoModelForCausalLM, AutoTokenizer; AutoModelForCausalLM.from_pretrained('HuggingFaceTB/SmolLM-135M-Instruct', trust_remote_code=True); AutoTokenizer.from_pretrained('HuggingFaceTB/SmolLM-135M-Instruct', trust_remote_code=True)"
RUN python -c "from diffusers import StableDiffusionPipeline; StableDiffusionPipeline.from_pretrained('runwayml/stable-diffusion-v1-5')"
# Set permissions for all directories
RUN chmod -R 777 /app
# Make port 7860 available to the world outside this container
EXPOSE 7860
# Run app.py when the container launches
CMD ["python", "app.py"]