Create Dockerfile
Browse files- Dockerfile +75 -0
Dockerfile
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use the official Python image as a parent image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set environment variables for non-interactive installation
|
| 5 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
+
ENV XDG_CACHE_HOME=/tmp/.cache
|
| 7 |
+
|
| 8 |
+
# Install system dependencies
|
| 9 |
+
RUN apt-get update && \
|
| 10 |
+
apt-get install -y \
|
| 11 |
+
ffmpeg \
|
| 12 |
+
unzip \
|
| 13 |
+
imagemagick \
|
| 14 |
+
libx11-dev \
|
| 15 |
+
libxtst6 \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
# Install Arial fonts (including bold)
|
| 20 |
+
RUN apt-get update && apt-get install -y \
|
| 21 |
+
fonts-liberation
|
| 22 |
+
|
| 23 |
+
# Modify ImageMagick's security policy to allow @ symbol usage
|
| 24 |
+
RUN sed -i 's/<policy domain="path" rights="none" pattern="@\*"/<!-- <policy domain="path" rights="none" pattern="@\*" -->/' /etc/ImageMagick-6/policy.xml
|
| 25 |
+
|
| 26 |
+
# Create a non-root user and group
|
| 27 |
+
RUN addgroup --system appgroup && adduser --system appuser --ingroup appgroup
|
| 28 |
+
|
| 29 |
+
# Set the working directory in the container
|
| 30 |
+
WORKDIR /app
|
| 31 |
+
|
| 32 |
+
# Create the /tmp/.cache/whisper directory, give full permissions (777)
|
| 33 |
+
RUN mkdir -p /tmp/.cache/whisper && \
|
| 34 |
+
chmod -R 777 /tmp/.cache/whisper
|
| 35 |
+
|
| 36 |
+
# Copy the Flask app and Gunicorn launcher script
|
| 37 |
+
#COPY flask_app.py ./
|
| 38 |
+
|
| 39 |
+
# Copy the zip file to the container
|
| 40 |
+
COPY max_ai.zip ./
|
| 41 |
+
|
| 42 |
+
# Unzip the file and install Python dependencies
|
| 43 |
+
RUN unzip max_ai.zip && \
|
| 44 |
+
cd max_ai && \
|
| 45 |
+
pip install --upgrade pip && \
|
| 46 |
+
pip install -r requirements.txt
|
| 47 |
+
|
| 48 |
+
# Install additional Python packages
|
| 49 |
+
RUN pip install gunicorn flask moviepy google_auth_oauthlib google-api-python-client google-auth-httplib2
|
| 50 |
+
|
| 51 |
+
# Fix the issue with PIL.Image.ANTIALIAS in moviepy
|
| 52 |
+
RUN [ -f /usr/local/lib/python3.10/site-packages/moviepy/video/fx/resize.py ] && \
|
| 53 |
+
sed -i 's/Image.ANTIALIAS/Image.LANCZOS/g' /usr/local/lib/python3.10/site-packages/moviepy/video/fx/resize.py || \
|
| 54 |
+
echo "resize.py not found, skipping sed command"
|
| 55 |
+
|
| 56 |
+
# Set ImageMagick binary path in MoviePy config (Linux-based)
|
| 57 |
+
RUN echo "IMAGEMAGICK_BINARY = '/usr/bin/convert'" >> /usr/local/lib/python3.10/site-packages/moviepy/config.py
|
| 58 |
+
|
| 59 |
+
# Install additional Python packages
|
| 60 |
+
#RUN pip install gunicorn flask moviepy google_auth_oauthlib google-api-python-client google-auth-httplib2
|
| 61 |
+
|
| 62 |
+
# Fix the issue with PIL.Image.ANTIALIAS in moviepy
|
| 63 |
+
#RUN sed -i 's/Image.ANTIALIAS/Image.LANCZOS/g' /usr/local/lib/python3.10/site-packages/moviepy/video/fx/resize.py
|
| 64 |
+
|
| 65 |
+
# Set ImageMagick binary path in MoviePy config (Linux-based)
|
| 66 |
+
#RUN echo "IMAGEMAGICK_BINARY = '/usr/bin/convert'" >> /usr/local/lib/python3.10/site-packages/moviepy/config.py
|
| 67 |
+
|
| 68 |
+
# Switch to the non-root user
|
| 69 |
+
USER appuser
|
| 70 |
+
|
| 71 |
+
# Expose the port Gunicorn will run on
|
| 72 |
+
EXPOSE 10000
|
| 73 |
+
|
| 74 |
+
# Command to run Gunicorn directly
|
| 75 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:10000", "flask_app:app"]
|