black44 commited on
Commit
202b453
·
verified ·
1 Parent(s): f7a2c0c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +9 -11
Dockerfile CHANGED
@@ -1,28 +1,26 @@
1
- # Use the official Python 3.9 slim image as the base image
2
  FROM python:3.9-slim
3
 
4
- # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Copy the requirements file into the container
8
- COPY requirements.txt .
 
 
9
 
10
- # Install the required Python dependencies
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Download the model and tokenizer
14
- RUN mkdir -p /app/models && \
15
  python -c "from transformers import AutoTokenizer, AutoProcessor; \
16
  tokenizer = AutoTokenizer.from_pretrained('suno/bark'); \
17
  processor = AutoProcessor.from_pretrained('suno/bark'); \
18
  tokenizer.save_pretrained('/app/models/suno-bark'); \
19
  processor.save_pretrained('/app/models/suno-bark')"
20
 
 
21
  COPY app.py .
22
 
23
- ENV TRANSFORMERS_CACHE=/app/.cache
24
- ENV HF_HOME=/app/.cache
25
-
26
  EXPOSE 7860
27
-
28
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
+ # Create and configure cache directory
6
+ RUN mkdir -p /app/.cache && chmod 777 /app/.cache
7
+ ENV TRANSFORMERS_CACHE=/app/.cache
8
+ ENV HF_HOME=/app/.cache
9
 
10
+ # Install dependencies
11
+ COPY requirements.txt .
12
  RUN pip install --no-cache-dir -r requirements.txt
13
 
14
+ # Pre-download the model (replace 'suno/bark' with a valid model if needed)
15
+ RUN mkdir -p /app/models/suno-bark && \
16
  python -c "from transformers import AutoTokenizer, AutoProcessor; \
17
  tokenizer = AutoTokenizer.from_pretrained('suno/bark'); \
18
  processor = AutoProcessor.from_pretrained('suno/bark'); \
19
  tokenizer.save_pretrained('/app/models/suno-bark'); \
20
  processor.save_pretrained('/app/models/suno-bark')"
21
 
22
+ # Copy application code
23
  COPY app.py .
24
 
 
 
 
25
  EXPOSE 7860
 
26
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]