imagebind / Dockerfile
fcastrovilli's picture
fix: change port to `7860`
787d79c
# Stage 1: Build stage
FROM python:3.10-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
git \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
# Switch to non-root user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy requirements and setup scripts
COPY --chown=user requirements.txt setup_imagebind.py README.md main.py ./
# Install dependencies into a virtual environment
RUN python -m venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Run setup script to download ImageBind
RUN python setup_imagebind.py
# Install ImageBind
RUN pip install --no-cache-dir .
# Stage 2: Runtime stage
FROM python:3.10-slim
# Install runtime dependencies only
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 user
# Switch to non-root user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder --chown=user /app/venv /app/venv
ENV PATH="/app/venv/bin:$PATH"
# Copy ImageBind from builder
COPY --from=builder --chown=user /app/imagebind* .
COPY --from=builder --chown=user /app/setup.py .
COPY --from=builder --chown=user /app/build .
# Copy application code
COPY --chown=user main.py .
# Expose the port
EXPOSE 7860
# Command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]