mf-123 / Dockerfile
Port443's picture
Update Dockerfile
5d1a9b3 verified
FROM python:3.13-slim-bookworm AS builder
WORKDIR /mediafusion
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends git curl build-essential && \
pip install --upgrade pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Clone the MediaFusion repository
RUN git clone https://github.com/mhdzumair/MediaFusion.git .
# Create the mediafusion user with a specified home directory
RUN groupadd -r mediafusion && \
useradd --no-log-init -r -g mediafusion -m -d /home/mediafusion mediafusion
RUN chown -R mediafusion:mediafusion /mediafusion
USER mediafusion
# Set the PATH environment variable to include the local bin directory
ENV PATH="/home/mediafusion/.local/bin:$PATH"
ENV PYTHONUNBUFFERED=1
# Install Python dependencies directly from the cloned repository
RUN pip install -r requirements.txt # Assuming there's a requirements.txt in the repo
# Install uv
COPY --from=ghcr.io/astral-sh/uv:0.6.3 /uv /uvx /bin/
RUN --mount=type=cache,target=/mediafusion/.cache/uv \
uv sync --frozen --no-install-project --compile-bytecode
FROM python:3.13-slim-bookworm AS runtime
ARG VERSION
WORKDIR /mediafusion
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create the mediafusion user with a specified home directory
RUN groupadd -r mediafusion && \
useradd --no-log-init -r -g mediafusion -m -d /home/mediafusion mediafusion
# Copy the Python environment and other necessary files from the builder stage
COPY --from=builder --chown=mediafusion:mediafusion /mediafusion/.venv /mediafusion/.venv
ENV PATH="/mediafusion/.venv/bin:$PATH"
ENV VERSION=${VERSION}
# Copy the startup script
COPY --chown=mediafusion:mediafusion ./startup.sh /mediafusion/startup.sh
RUN chmod +x /mediafusion/startup.sh
# Set the command to run the startup script
CMD ["/startup.sh"]