Add docker deploy

This commit is contained in:
itqop 2025-07-19 17:29:16 +03:00
parent 52931caf3c
commit 900065b158
3 changed files with 160 additions and 0 deletions

71
.dockerignore Normal file
View File

@ -0,0 +1,71 @@
__pycache__
*.pyc
*.pyo
*.pyd
.Python
env
pip-log.txt
pip-delete-this-directory.txt
.tox
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.log
.git
.mypy_cache
.pytest_cache
.hypothesis
.ruff_cache
.DS_Store
.vscode
.idea
*.swp
*.swo
*~
*.md
!README.md
.env
.env.local
.env.*.local
.env.production
.env.staging
storage/chroma/*
!storage/chroma/.gitkeep
articles_konsol_pro/*
!articles_konsol_pro/.gitkeep
scripts/
src/tests/
src/__pycache__/
*.tmp
*.temp
*.bak
*.backup
Dockerfile*
docker-compose*
.dockerignore
.github
.gitlab-ci.yml
.travis.yml
.circleci
.gitea
logs/
*.log
.venv/
venv/
env/
Техническое задание.md

38
Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM python:3.10-slim
LABEL maintainer="AI Email Assistant Team"
LABEL version="1.0.0"
LABEL description="AI Email Assistant with RAG and LangGraph"
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
RUN apt-get update && apt-get install -y \
gcc \
g++ \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
COPY . .
RUN mkdir -p /app/storage/chroma /app/data/articles_konsol_pro && \
chown -R appuser:appuser /app
USER appuser
ENV PYTHONPATH=/app
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/healthz || exit 1
CMD ["uvicorn", "src.app.main:app", "--host", "0.0.0.0", "--port", "8000"]

51
docker-compose.yml Normal file
View File

@ -0,0 +1,51 @@
version: '3.8'
services:
ai-email-assistant:
build:
context: .
dockerfile: Dockerfile
container_name: ai-email-assistant
ports:
- "8000:8000"
environment:
- LLM_PROVIDER=openai
- LLM_MODEL=gpt-4o
- EMBEDDING_MODEL=text-embedding-3-large
- OPENAI_API_KEY=${OPENAI_API_KEY}
- GEMINI_API_KEY=${GEMINI_API_KEY}
- CHROMA_PERSIST_DIR=/app/storage/chroma
- TOP_K=30
- TOP_N_CONTEXT=6
- MAX_TOKENS_COMPLETION=1024
- LANGGRAPH_TRACING=false
- SERVICE_LANG=ru
- SALES_REP_NAME=Команда Консоль.Про
- CHUNK_SIZE=500
- CHUNK_OVERLAP=100
- API_SECRET_KEY=${API_SECRET_KEY:-secret}
- PYTHONPATH=/app
- PYTHONUNBUFFERED=1
- PYTHONDONTWRITEBYTECODE=1
volumes:
- ./storage/chroma:/app/storage/chroma:rw
- ./data:/app/data:ro
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/healthz"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
restart: unless-stopped
deploy:
resources:
limits:
memory: 2G
cpus: '1.0'
reservations:
memory: 512M
cpus: '0.5'
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:noexec,nosuid,size=100m