-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.6 KB
/
Copy pathDockerfile
File metadata and controls
54 lines (38 loc) · 1.6 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
# Stage 1: Build & Requirements
FROM python:3.11-slim AS builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install poetry
RUN pip install --no-cache-dir poetry==2.3.2
# Configure poetry to not create a virtual environment since Docker is already isolated
RUN poetry config virtualenvs.create false
WORKDIR /app
# Copy dependency files first to leverage Docker cache
COPY pyproject.toml poetry.lock ./
# API image only needs core runtime dependencies. Heavy vector DB extras are opt-in.
RUN poetry install --no-root --only main
# Stage 2: Production runtime
FROM python:3.11-slim AS runtime
# Create a non-root user to run the application for security
RUN addgroup --system appgroup && adduser --system --group appuser
WORKDIR /app
# Copy installed python dependencies from builder
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY agentkit ./agentkit
COPY README.md ./
COPY LICENSE ./
# Set permissions
RUN chown -R appuser:appgroup /app
# Switch to non-root user
USER appuser
# Expose port for FastAPI
EXPOSE 8000
# Healthcheck (runtime imajında ek bir curl paketi gerektirmez)
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD ["python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health', timeout=5)"]
# Start the AgentKit Server
CMD ["python", "-m", "agentkit", "deploy", "--host", "0.0.0.0", "--port", "8000"]