tzintsunzu commited on
Commit
c4539ec
1 Parent(s): 8fc2958

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -0
Dockerfile ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set the working directory in the container
4
+ WORKDIR /app
5
+
6
+ # Copy the current directory contents into the container at /app
7
+ COPY . /app
8
+
9
+ # Install necessary packages
10
+ RUN apt-get update && apt-get install -y git
11
+
12
+ # Install any needed packages specified in requirements.txt
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # Install additional dependencies
16
+ RUN pip install torch transformers diffusers gradio pandas tqdm accelerate
17
+
18
+ # Create writable cache directory and set permissions
19
+ RUN mkdir -p /app/cache && chmod -R 777 /app/cache
20
+
21
+ # Set environment variables for cache directories
22
+ ENV HF_HOME=/app/cache
23
+ ENV MPLCONFIGDIR=/app/cache/matplotlib
24
+
25
+ # Download models
26
+ 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)"
27
+ RUN python -c "from diffusers import StableDiffusionPipeline; StableDiffusionPipeline.from_pretrained('runwayml/stable-diffusion-v1-5')"
28
+
29
+ # Set permissions for all directories
30
+ RUN chmod -R 777 /app
31
+
32
+ # Make port 7860 available to the world outside this container
33
+ EXPOSE 7860
34
+
35
+ # Run app.py when the container launches
36
+ CMD ["python", "app.py"]