From 4649882c275ed7858196d82a23e5bc6c7a5af22c Mon Sep 17 00:00:00 2001 From: "Luluka.Badikina" Date: Sun, 21 Dec 2025 22:52:49 +0300 Subject: [PATCH 1/3] docker backend --- Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..43088e5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.11-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + gcc \ + postgresql-client \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENV PYTHONPATH=/app +ENV PYTHONUNBUFFERED=1 + +EXPOSE 8000 + + +CMD ["python", "-m", "uvicorn", "src.presentation.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"] \ No newline at end of file -- 2.47.2 From 84556dd220a8518482fbfa5252ed032208d06f14 Mon Sep 17 00:00:00 2001 From: "Luluka.Badikina" Date: Sun, 21 Dec 2025 23:23:50 +0300 Subject: [PATCH 2/3] docker compose --- Dockerfile => backend/Dockerfile | 0 docker-compose.yml | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) rename Dockerfile => backend/Dockerfile (100%) create mode 100644 docker-compose.yml diff --git a/Dockerfile b/backend/Dockerfile similarity index 100% rename from Dockerfile rename to backend/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ad74178 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +services: + postgres: + image: postgres:15-alpine + restart: unless-stopped + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: lawyer_ai + ports: + - "5432:5432" + volumes: + - postgres_data:/var/lib/postgresql/data + + qdrant: + image: qdrant/qdrant:latest + restart: unless-stopped + ports: + - "6333:6333" + volumes: + - qdrant_data:/qdrant/storage + + redis: + image: redis:7-alpine + restart: unless-stopped + ports: + - "6379:6379" + volumes: + - redis_data:/data + + backend: + build: ./backend + restart: unless-stopped + environment: + POSTGRES_HOST: postgres + POSTGRES_PORT: 5432 + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: lawyer_ai + QDRANT_HOST: qdrant + QDRANT_PORT: 6333 + REDIS_HOST: redis + REDIS_PORT: 6379 + DEBUG: "true" + ports: + - "8000:8000" + depends_on: + - postgres + - qdrant + - redis + +volumes: + postgres_data: + qdrant_data: + redis_data: \ No newline at end of file -- 2.47.2 From c210c4a3c52bbf868ff4845f7aa83a3a8e4a86da Mon Sep 17 00:00:00 2001 From: "Luluka.Badikina" Date: Mon, 22 Dec 2025 23:33:30 +0300 Subject: [PATCH 3/3] docker + docker compose + ignore + drone --- .dockerignore | 35 +++++++++++++++++++++++++++++++++++ .gitignore | 1 - docker-compose.yml | 45 ++++++++++++++++++++++++++++++++++++--------- drone.yml | 30 ++++++++++++++++++++++++++++++ tg_bot/Dockerfile | 18 ++++++++++++++++++ 5 files changed, 119 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 drone.yml create mode 100644 tg_bot/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8591ab4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,35 @@ +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python + +venv/ +env/ +ENV/ +.venv/ + +.vscode/ +.idea/ +*.swp +*.swo +*~ +.DS_Store + +.git/ +.gitignore +.gitattributes + +Dockerfile* +docker-compose*.yml +.dockerignore + +drone.yml + +tmp/ +temp/ +*.tmp + +Thumbs.db +.DS_Store + diff --git a/.gitignore b/.gitignore index 9f99d40..436fb97 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -# Python __pycache__/ *.pyc *.pyo diff --git a/docker-compose.yml b/docker-compose.yml index ad74178..495c444 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,10 +2,12 @@ services: postgres: image: postgres:15-alpine restart: unless-stopped + env_file: + - .env environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: lawyer_ai + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} ports: - "5432:5432" volumes: @@ -30,17 +32,22 @@ services: backend: build: ./backend restart: unless-stopped + env_file: + - .env environment: POSTGRES_HOST: postgres - POSTGRES_PORT: 5432 - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: lawyer_ai + POSTGRES_PORT: ${POSTGRES_PORT} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} QDRANT_HOST: qdrant - QDRANT_PORT: 6333 + QDRANT_PORT: ${QDRANT_PORT} REDIS_HOST: redis - REDIS_PORT: 6379 + REDIS_PORT: ${REDIS_PORT} DEBUG: "true" + SECRET_KEY: ${SECRET_KEY} + APP_NAME: ${APP_NAME} + CORS_ORIGINS: ${CORS_ORIGINS} ports: - "8000:8000" depends_on: @@ -48,6 +55,26 @@ services: - qdrant - redis + tg_bot: + build: ./tg_bot + restart: unless-stopped + env_file: + - .env + environment: + POSTGRES_HOST: postgres + POSTGRES_PORT: ${POSTGRES_PORT} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN} + DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY} + DEEPSEEK_API_URL: ${DEEPSEEK_API_URL:-https://api.deepseek.com/v1/chat/completions} + YANDEX_OCR_API_KEY: ${YANDEX_OCR_API_KEY} + DEBUG: "true" + depends_on: + - postgres + - backend + volumes: postgres_data: qdrant_data: diff --git a/drone.yml b/drone.yml new file mode 100644 index 0000000..ea0b9a7 --- /dev/null +++ b/drone.yml @@ -0,0 +1,30 @@ +kind: pipeline +type: docker +name: deploy-backend + +trigger: + event: + - push + - pull_request + - tag + branch: + - main + +steps: + - name: deploy-backend + image: appleboy/drone-ssh + settings: + host: + from_secret: server_host + username: + from_secret: server_username + password: + from_secret: server_password + port: 22 + script: + - cd BETTERCALLPRASKOVIA + - git pull origin main + - docker-compose stop backend tg_bot + - docker-compose up --build -d backend tg_bot + - docker system prune -f + diff --git a/tg_bot/Dockerfile b/tg_bot/Dockerfile new file mode 100644 index 0000000..8bbf51d --- /dev/null +++ b/tg_bot/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.11-slim + +WORKDIR /app + +RUN apt-get update && apt-get install -y \ + gcc \ + postgresql-client \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENV PYTHONPATH=/app +ENV PYTHONUNBUFFERED=1 + +CMD ["python", "tg_bot/main.py"] \ No newline at end of file -- 2.47.2