-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathDockerfile
More file actions
74 lines (56 loc) · 1.99 KB
/
Dockerfile
File metadata and controls
74 lines (56 loc) · 1.99 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Builder stage - use slim Python image
FROM python:3.12-slim-bookworm AS builder
# Set working directory
WORKDIR /app
# Install uv manually (following official installation)
ARG UV_VERSION=0.5.11
ENV UV_VERSION=${UV_VERSION}
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh \
&& rm -rf /var/lib/apt/lists/*
# Add uv to PATH
ENV PATH="/root/.local/bin:$PATH"
# Enable bytecode compilation for faster startup
ENV UV_COMPILE_BYTECODE=1
# Copy uv cache to a predictable location for caching
ENV UV_LINK_MODE=copy
# Install dependencies first (separate layer for better caching)
# Copy only dependency files first for better layer caching
COPY uv.lock pyproject.toml README.md ./
RUN uv sync --frozen --no-install-project --no-dev
# Copy the project source code
COPY . /app
# Sync the project itself (now including the source code)
RUN uv sync --frozen --no-dev
# Final runtime stage - use slim Python image
FROM python:3.12-slim-bookworm
# Set working directory
WORKDIR /app
# Install Node.js (required for MCP tools) and uv
ENV UV_VERSION=0.5.11
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
ca-certificates \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh \
&& rm -rf /var/lib/apt/lists/*
# Add uv to PATH
ENV PATH="/root/.local/bin:$PATH"
# Copy the virtual environment from the builder
COPY --from=builder /app/.venv /app/.venv
# Copy the application code
COPY --from=builder /app /app
# Add virtual environment to PATH
ENV PATH="/app/.venv/bin:$PATH"
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PORT=8080
ENV CONTAINER_ENV=true
ENV ENVIRONMENT=production
# Expose port 8080 (Azure Container Apps default)
EXPOSE 8080
# Run the application using uv run (just like locally)
CMD ["uv", "run", "app"]