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