bravedims commited on
Commit
297f320
·
1 Parent(s): f855731

Improve Docker build process and add startup script

Browse files

- Add git-lfs to system dependencies for model downloading
- Create start.sh script to handle model downloads at runtime
- Update Dockerfile to use startup script instead of direct python execution
- This should resolve build timeouts and missing model issues

Files changed (2) hide show
  1. Dockerfile +8 -3
  2. start.sh +14 -0
Dockerfile CHANGED
@@ -24,6 +24,7 @@ RUN apt-get update && apt-get install -y \
24
  libtcmalloc-minimal4 \
25
  ffmpeg \
26
  tzdata \
 
27
  && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
28
  && apt-get clean \
29
  && rm -rf /var/lib/apt/lists/*
@@ -36,6 +37,7 @@ ENV PATH="/home/user/.local/bin:$PATH"
36
  ENV PYTHONPATH=/app
37
  ENV GRADIO_SERVER_NAME=0.0.0.0
38
  ENV GRADIO_SERVER_PORT=7860
 
39
 
40
  # Set working directory
41
  WORKDIR /app
@@ -48,10 +50,13 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
48
  COPY --chown=user . /app
49
 
50
  # Create necessary directories
51
- RUN mkdir -p pretrained_models outputs
 
 
 
52
 
53
  # Expose port (required by HF Spaces to be 7860)
54
  EXPOSE 7860
55
 
56
- # Start the application
57
- CMD ["python", "app.py"]
 
24
  libtcmalloc-minimal4 \
25
  ffmpeg \
26
  tzdata \
27
+ git-lfs \
28
  && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
29
  && apt-get clean \
30
  && rm -rf /var/lib/apt/lists/*
 
37
  ENV PYTHONPATH=/app
38
  ENV GRADIO_SERVER_NAME=0.0.0.0
39
  ENV GRADIO_SERVER_PORT=7860
40
+ ENV HF_HOME=/app/cache
41
 
42
  # Set working directory
43
  WORKDIR /app
 
50
  COPY --chown=user . /app
51
 
52
  # Create necessary directories
53
+ RUN mkdir -p pretrained_models outputs cache
54
+
55
+ # Make scripts executable
56
+ RUN chmod +x download_models.sh start.sh
57
 
58
  # Expose port (required by HF Spaces to be 7860)
59
  EXPOSE 7860
60
 
61
+ # Start the application using startup script
62
+ CMD ["./start.sh"]
start.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ echo "Starting AI Avatar Chat application..."
4
+
5
+ # Check if models exist, if not download them
6
+ if [ ! -d "pretrained_models/OmniAvatar-14B" ]; then
7
+ echo "Models not found, downloading..."
8
+ ./download_models.sh
9
+ else
10
+ echo "Models already exist, skipping download..."
11
+ fi
12
+
13
+ echo "Starting Python application..."
14
+ python app.py