Spaces:
Sleeping
Sleeping
File size: 1,649 Bytes
342e0fb | 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 | # Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
imagemagick \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
build-essential \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Fix ImageMagick policy to allow processing (checking both version 6 and 7)
RUN if [ -f /etc/ImageMagick-6/policy.xml ]; then \
sed -i 's/domain="path" rights="none" pattern="@\*"/domain="path" rights="read|write" pattern="@\*"/g' /etc/ImageMagick-6/policy.xml; \
fi; \
if [ -f /etc/ImageMagick-7/policy.xml ]; then \
sed -i 's/domain="path" rights="none" pattern="@\*"/domain="path" rights="read|write" pattern="@\*"/g' /etc/ImageMagick-7/policy.xml; \
fi
# Create a non-root user
RUN useradd -m -u 1000 user
# Set working directory and ownership
WORKDIR /app
RUN chown -R user:user /app
# Switch to non-root user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Copy requirements and install
COPY --chown=user:user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application
COPY --chown=user:user . /app
# Create necessary directories with correct permissions
RUN mkdir -p uploads outputs/viral_clips temp logs fonts && \
chmod -R 755 uploads outputs/viral_clips temp logs fonts
# Expose the port
EXPOSE 7860
# Run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|