Spaces:
Build error

File size: 1,971 Bytes
7fa9e33
6d1b910
7fa9e33
 
 
 
 
 
 
 
 
 
 
98e2868
7fa9e33
98e2868
 
 
2fd4491
7fa9e33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
847dee2
cdb6bc5
 
847dee2
 
7fa9e33
 
02ae6a5
7fa9e33
 
c653ee9
7fa9e33
b033e58
 
7fa9e33
 
 
 
b033e58
 
17180f1
6712e26
7fa9e33
b033e58
7473a66
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Use the official Python image as a parent image
FROM python:3.10-slim

# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV XDG_CACHE_HOME=/tmp/.cache

# Install system dependencies
RUN apt-get update && \
    apt-get install -y \
    ffmpeg \
    unzip \
    imagemagick \
    libx11-dev \
    libxtst6 \
    libjpeg-dev \
    zlib1g-dev \
    libsm6 \
    libxext6 \
    && rm -rf /var/lib/apt/lists/*

# Install Arial fonts (including bold)
RUN apt-get update && apt-get install -y \
    fonts-liberation 

# Modify ImageMagick's security policy to allow @ symbol usage
RUN sed -i 's/<policy domain="path" rights="none" pattern="@\*"/<!-- <policy domain="path" rights="none" pattern="@\*" -->/' /etc/ImageMagick-6/policy.xml

# Create a non-root user and group
RUN addgroup --system appgroup && adduser --system appuser --ingroup appgroup

# Set the working directory in the container
WORKDIR /app

# Create the /tmp/.cache/whisper directory, give full permissions (777)
RUN mkdir -p /tmp/.cache/whisper && \
    chmod -R 777 /tmp/.cache/whisper

# Copy the zip file to the container
COPY max_ai.zip ./

# Unzip the file and install Python dependencies
RUN unzip max_ai.zip
WORKDIR /app/max_ai

RUN pip install --upgrade pip && \
    pip install -r requirements.txt

# Install additional Python packages
RUN pip install gradio moviepy==1.0.3 openai-whisper flask gunicorn

# Fix the issue with PIL.Image.ANTIALIAS in moviepy
RUN sed -i 's/Image.ANTIALIAS/Image.LANCZOS/g' /usr/local/lib/python3.10/site-packages/moviepy/video/fx/resize.py

# Set ImageMagick binary path in MoviePy config
RUN echo "IMAGEMAGICK_BINARY = '/usr/bin/convert'" >> /usr/local/lib/python3.10/site-packages/moviepy/config.py

# Switch to the non-root user
USER appuser

# Expose the port Gradio will run on
EXPOSE 7860
COPY gradio_app.py /app/max_ai
COPY flask_app.py /app/max_ai

# Command to run the Gradio app
CMD ["python", "flask_app.py"]