codeMcp / Dockerfile
sarveshpatel's picture
Update Dockerfile
9575fab verified
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
CODE_STORAGE_DIR=/app/code_storage \
ENV_TYPE=venv-uv \
UV_VENV_PATH=/app/executor_venv \
WORKERS=4 \
MAX_CONCURRENT_EXECUTIONS=20 \
EXECUTION_TIMEOUT=120 \
HF_SPACE=1
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Install uv for fast package management
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Fix PATH - uv installs to /root/.local/bin
ENV PATH="/root/.local/bin:$PATH"
# Verify uv is accessible
RUN uv --version
# Create app directory
WORKDIR /app
# Copy requirements first for layer caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Create the executor virtual environment using uv
RUN uv venv /app/executor_venv && \
. /app/executor_venv/bin/activate && \
uv pip install numpy pandas matplotlib scikit-learn requests pillow scipy sympy && \
deactivate
# Create code storage directory
RUN mkdir -p /app/code_storage && chmod 777 /app/code_storage
# Copy application code
COPY . .
# Copy and set permissions for start script
COPY scripts/start.sh /app/scripts/start.sh
RUN chmod +x /app/scripts/start.sh
# Expose HF Spaces port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Start the application
CMD ["/app/scripts/start.sh"]