-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (73 loc) · 3.28 KB
/
Copy pathDockerfile
File metadata and controls
96 lines (73 loc) · 3.28 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Use Python 3.11 slim image as base
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Install system dependencies including Node.js and npm (and remove what's not needed after installation)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential curl gnupg \
&& curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs \
&& apt-get purge -y curl gnupg \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g mcp-remote \
&& npm cache clean --force
RUN pip install uv
# Copy requirements first for better caching
COPY requirements.txt ./requirements.txt
# Install Python dependencies
RUN uv pip install --no-cache-dir --system -r ./requirements.txt
# Set Playwright browser path to a shared directory accessible by non-root user
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
# Install Playwright browser binaries and system dependencies (as root)
RUN python -m playwright install --with-deps chromium \
&& chmod -R 755 /ms-playwright
# Install additional dependencies mentioned in README
# RUN uv pip install --no-cache-dir --system google-adk litellm
# Create the user and group first in a separate layer
RUN addgroup --system appuser && adduser --system -home /home/appuser --ingroup appuser appuser
# Set the HOME environment variable to the user's home directory
ENV HOME=/home/appuser
# Create data, artifacts, and agents directories
RUN mkdir -p /app/data /app/artifacts /app/agents
RUN chown -R appuser:appuser /app
# Copy files with the correct ownership directly
# Copy only specified agents based on build argument
ARG AGENTS_LIST=""
RUN echo "Building with agents: $AGENTS_LIST"
# Agents directory already created above
# # Copy all agents first, then remove unwanted ones
COPY --chown=appuser:appuser agents/ ./agents/
# Remove agents not in the list
RUN echo "$AGENTS_LIST" | tr ',' '\n' > /tmp/agents_list.txt && \
for dir in ./agents/*/; do \
agent_name=$(basename "$dir"); \
if ! grep -q "^${agent_name}$" /tmp/agents_list.txt; then \
echo "Removing agent: $agent_name"; \
rm -rf "$dir"; \
else \
echo "Keeping agent: $agent_name"; \
fi; \
done && \
rm -f /tmp/agents_list.txt
# Copy the shared directories -- should be copied in each deployment
COPY --chown=appuser:appuser shared/ ./shared/
COPY --chown=appuser:appuser server/ ./server/
COPY --chown=appuser:appuser auth_server.py ./auth_server.py
COPY --chown=appuser:appuser adk_main.py ./adk_main.py
COPY --chown=appuser:appuser langgraph_main.py ./langgraph_main.py
COPY --chown=appuser:appuser langgraph.json ./langgraph.json
COPY --chown=appuser:appuser templates/ ./templates/
COPY --chown=appuser:appuser static/ ./static/
# Set environment variables
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
# Switch to non-root user
USER appuser
# Expose port for web interface (if needed)
EXPOSE 8000
# Uses Python rather than curl, which is purged above. The long start period covers
# migrations and MCP init, which run before uvicorn binds.
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=4)"
# Default command: run auth server (same as docker-compose)
CMD ["python", "auth_server.py"]