# Dockerfile for mcp_hackathon Gradio application # 1. Base Image FROM python:3.12-slim # 3. Install system dependencies (git) and uv (Python package manager) RUN apt-get update && \ apt-get install -y build-essential cmake && \ apt-get install -y --no-install-recommends git && \ pip install --no-cache-dir uv && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Create non-root user RUN useradd -m -u 1000 user USER user ENV HOME=/home/user # Set uv cache location ENV UV_CACHE_DIR="${HOME}/.cache/uv" RUN mkdir -p "${UV_CACHE_DIR}" # Use app directory WORKDIR /home/user/app # 5. Clone the repository # Cloning into the current directory (/app) RUN git clone https://github.com/keshan/mcp_hackathon.git . COPY --chown=user:user . . # Install uv and run sync RUN pip install --no-cache-dir uv # 2. Set Environment Variables # PYTHONDONTWRITEBYTECODE: Prevents Python from writing .pyc files to disc (equivalent to python -B) # PYTHONUNBUFFERED: Prevents Python from buffering stdin/stdout/stderr (equivalent to python -u) ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # 6. Install Python dependencies using uv # uv sync will read pyproject.toml and install dependencies. # It will create and use a virtual environment in .venv by default. RUN uv sync && rm -rf "${UV_CACHE_DIR}/git-v0" # 7. Expose the port Gradio runs on (default is 7860) EXPOSE 7860 # 8. Command to run the application # 'uv run' will execute the command within the context of the virtual environment. # --host 0.0.0.0 makes the app accessible from outside the container. # --port 7860 explicitly sets the Gradio port. CMD ["uv", "run", "src/ui/app.py", "--host", "0.0.0.0", "--port", "7860"]