Spaces:
Running
Running
File size: 2,076 Bytes
d9e79bd 0c78d95 dc99ae6 17c0bc1 77e7008 3c1d78b d9e79bd 3c1d78b 371c310 d9e79bd 0c78d95 5b1e9ea 0c78d95 5b1e9ea 77e7008 7f8082a 0c78d95 19fd313 5b1e9ea 19fd313 f74a9b7 19fd313 f74a9b7 b110fef 77e7008 b110fef 17c0bc1 77e7008 17c0bc1 77e7008 dc99ae6 77e7008 371c310 dc99ae6 5b1e9ea 17c0bc1 77e7008 |
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 |
FROM ubuntu:22.04
# Prevent interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive
# Set environment variables for MoviePy
ENV IMAGEMAGICK_BINARY=/usr/bin/convert
ENV IMAGEIO_FFMPEG_EXE=/usr/bin/ffmpeg
# Install system dependencies
RUN apt-get update && apt-get install -y \
software-properties-common && \
add-apt-repository -y ppa:ubuntu-toolchain-r/test && \
apt-get update && apt-get install -y \
python3.9 \
python3-pip \
ffmpeg \
imagemagick \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m appuser
# Set working directory
WORKDIR /app
# Copy application code
COPY . .
# Install Python dependencies globally
RUN pip3 install -r requirements.txt
# Set ownership and permissions
RUN chown -R appuser:appuser /app && \
chown -R appuser:appuser /tmp && \
chmod -R 755 /app && \
chmod -R 777 /tmp
# Create required directories and set permissions
# Create required directories and set permissions
RUN mkdir -p /app/resources/audio && \
mkdir -p /app/resources/fonts && \
mkdir -p /app/resources/intro && \
mkdir -p /app/resources/temp_video && \
chown -R appuser:appuser /app && \
chmod -R 755 /app && \
chmod -R 777 /app/resources/temp_video
# Configure ImageMagick with a permissive policy
RUN mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak || true
RUN echo '<policymap>\
<policy domain="resource" name="memory" value="512MiB"/> \
<policy domain="resource" name="map" value="1GiB"/> \
<policy domain="resource" name="width" value="16KP"/> \
<policy domain="resource" name="height" value="16KP"/> \
<policy domain="resource" name="area" value="256MB"/> \
<policy domain="resource" name="disk" value="2GiB"/> \
<policy domain="path" rights="read|write" pattern="@*"/> \
<policy domain="path" rights="read|write" pattern="/tmp/*"/> \
</policymap>' > /etc/ImageMagick-6/policy.xml
# Switch to non-root user
USER appuser
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |