File size: 1,706 Bytes
7758664
 
 
 
 
e44c340
 
 
 
 
 
 
 
 
a18cb48
 
 
e44c340
 
 
 
 
 
 
f41d8de
 
 
a18cb48
 
e44c340
 
 
7758664
 
 
 
 
 
 
 
 
e44c340
7758664
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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"]