From 47a848fbcb7b65c825b6b546094678934013138d Mon Sep 17 00:00:00 2001 From: chiguyong Date: Fri, 5 Jun 2026 23:18:44 +0800 Subject: [PATCH] feat(deploy): add Dockerfile and .dockerignore for AgentKit Server - Multi-stage build (builder + runner) based on python:3.11-slim - Installs .[server] extra (fastapi + uvicorn) - Runs as non-root appuser - Health check on /api/v1/health - Default command: uvicorn configs.geo_server:create_geo_app --port 8001 --- .dockerignore | 16 ++++++++++++++++ Dockerfile | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6780192 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git +.gitignore +__pycache__/ +*.pyc +*.pyo +.pytest_cache/ +tests/ +docs/ +.coverage +*.egg-info/ +dist/ +build/ +*.egg +.env +.env.* +!.env.example diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dc62b6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +FROM python:3.11-slim AS builder + +WORKDIR /app + +COPY pyproject.toml README.md ./ +COPY src/ ./src/ + +RUN pip install --no-cache-dir --prefix=/install ".[server]" + +FROM python:3.11-slim AS runner + +WORKDIR /app + +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +COPY --from=builder /install /usr/local + +COPY pyproject.toml README.md ./ +COPY src/ ./src/ + +RUN addgroup --system --gid 1001 appuser \ + && adduser --system --uid 1001 appuser \ + && chown -R appuser:appuser /app + +USER appuser + +EXPOSE 8001 + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8001/api/v1/health')" + +CMD ["uvicorn", "configs.geo_server:create_geo_app", "--factory", "--host", "0.0.0.0", "--port", "8001"]