CXM06's picture
First commit - Individual test scripts present
d0c8d86
# ============================================================================
# AI IMAGE CAPTION GENERATOR - DOCKERFILE
# ============================================================================
# Multi-stage build for optimized production image
# Compatible with HuggingFace Spaces and local deployment
# ============================================================================
FROM python:3.10-slim as base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive
# Set working directory
WORKDIR /app
# ============================================================================
# DEPENDENCIES STAGE
# ============================================================================
FROM base as dependencies
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# ============================================================================
# RUNTIME STAGE
# ============================================================================
FROM base as runtime
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Copy Python dependencies from builder
COPY --from=dependencies /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=dependencies /usr/local/bin /usr/local/bin
# Copy application code
COPY . .
# Create necessary directories
RUN mkdir -p cache/models cache/analytics static/images/examples
# Set permissions
RUN chmod -R 755 /app
# Expose Gradio default port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Run the application
CMD ["python", "app.py"]