Files
ai-ffmpeg-cli/Dockerfile

49 lines
1.1 KiB
Docker

# Multi-stage Docker build for aiclip
FROM python:3.11-slim AS builder
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
WORKDIR /app
COPY pyproject.toml README.md LICENSE ./
COPY src ./src
RUN pip install --no-cache-dir build && \
python -m build --wheel && \
pip wheel --no-cache-dir --wheel-dir /app/wheels .
# Production stage
FROM python:3.11-slim
# Install ffmpeg and runtime dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd --create-home --shell /bin/bash aiclip
# Copy wheels and install
COPY --from=builder /app/wheels /tmp/wheels
RUN pip install --no-cache-dir /tmp/wheels/*.whl && \
rm -rf /tmp/wheels
# Switch to non-root user
USER aiclip
WORKDIR /home/aiclip
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD aiclip --help || exit 1
# Default command
ENTRYPOINT ["aiclip"]
CMD ["--help"]