File size: 1,304 Bytes
c4539ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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"]