fix: deployment — resolve dependency conflicts, add initial migration, CI/CD webhook

- Fix httpx/pydantic/redis version conflicts for litellm/aiogram/celery compatibility
- Add PYTHONPATH=/app to Dockerfile for alembic module resolution
- Skip Telegram webhook setup when URL is not HTTPS
- Fix FileUpload prop type mismatch in RecordingsPage
- Add alembic script.py.mako template and initial migration
- Configure docker-compose: port 8081, built frontend, no exposed internal ports
- Add deploy.sh and webhook-server.js for Gitea CI/CD auto-deploy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Admin
2026-04-07 13:49:12 +05:00
parent d2ef7785a4
commit 3e15f643d6
9 changed files with 216 additions and 16 deletions
+1
View File
@@ -2,6 +2,7 @@ FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/app
# System dependencies
RUN apt-get update && apt-get install -y \
+26
View File
@@ -0,0 +1,26 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
${upgrades if upgrades else "pass"}
def downgrade() -> None:
${downgrades if downgrades else "pass"}
@@ -0,0 +1,111 @@
"""initial
Revision ID: a7d968fceaaf
Revises:
Create Date: 2026-04-06 17:59:05.406839
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = 'a7d968fceaaf'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('prompt_templates',
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('description', sa.String(length=1000), nullable=False),
sa.Column('type', sa.Enum('client_survey', 'client_intro', 'internal', 'custom', name='templatetype'), nullable=False),
sa.Column('system_prompt', sa.Text(), nullable=False),
sa.Column('user_prompt', sa.Text(), nullable=False),
sa.Column('output_schema', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('is_default', sa.Boolean(), nullable=False),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('users',
sa.Column('username', sa.String(length=150), nullable=False),
sa.Column('email', sa.String(length=255), nullable=False),
sa.Column('password_hash', sa.String(length=255), nullable=False),
sa.Column('role', sa.Enum('admin', 'user', name='userrole'), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
op.create_table('recordings',
sa.Column('user_id', sa.Uuid(), nullable=False),
sa.Column('title', sa.String(length=500), nullable=False),
sa.Column('file_path', sa.String(length=1000), nullable=False),
sa.Column('file_size', sa.BigInteger(), nullable=False),
sa.Column('duration', sa.Float(), nullable=True),
sa.Column('format', sa.String(length=20), nullable=False),
sa.Column('source', sa.Enum('web', 'telegram', 'lensa', name='recordingsource'), nullable=False),
sa.Column('status', sa.Enum('uploaded', 'processing', 'done', 'error', name='recordingstatus'), nullable=False),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('transcriptions',
sa.Column('recording_id', sa.Uuid(), nullable=False),
sa.Column('text', sa.Text(), nullable=False),
sa.Column('segments', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('language', sa.String(length=10), nullable=True),
sa.Column('whisper_model', sa.String(length=50), nullable=False),
sa.Column('processing_time', sa.Float(), nullable=True),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['recording_id'], ['recordings.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('recording_id')
)
op.create_table('protocols',
sa.Column('transcription_id', sa.Uuid(), nullable=False),
sa.Column('template_id', sa.Uuid(), nullable=False),
sa.Column('content', postgresql.JSONB(astext_type=sa.Text()), nullable=False),
sa.Column('raw_text', sa.Text(), nullable=False),
sa.Column('llm_model', sa.String(length=100), nullable=False),
sa.Column('status', sa.Enum('generating', 'done', 'error', name='protocolstatus'), nullable=False),
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['template_id'], ['prompt_templates.id'], ),
sa.ForeignKeyConstraint(['transcription_id'], ['transcriptions.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('export_files',
sa.Column('protocol_id', sa.Uuid(), nullable=False),
sa.Column('format', sa.Enum('docx', 'pdf', 'md', name='exportformat'), nullable=False),
sa.Column('file_path', sa.String(length=1000), nullable=False),
sa.Column('file_size', sa.BigInteger(), nullable=False),
sa.Column('id', sa.Uuid(), nullable=False),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['protocol_id'], ['protocols.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('export_files')
op.drop_table('protocols')
op.drop_table('transcriptions')
op.drop_table('recordings')
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.drop_table('users')
op.drop_table('prompt_templates')
# ### end Alembic commands ###
+2 -2
View File
@@ -30,10 +30,10 @@ async def seed_default_templates():
@asynccontextmanager
async def lifespan(app: FastAPI):
await seed_default_templates()
if settings.telegram_bot_token:
if settings.telegram_bot_token and settings.telegram_webhook_url.startswith("https"):
await telegram_service.setup()
yield
if settings.telegram_bot_token:
if settings.telegram_bot_token and settings.telegram_webhook_url.startswith("https"):
await telegram_service.shutdown()
+4 -4
View File
@@ -10,7 +10,7 @@ psycopg2-binary==2.9.10
alembic==1.14.1
# Validation
pydantic==2.10.4
pydantic>=2.7.0,<2.10
pydantic-settings==2.7.1
# Auth
@@ -19,7 +19,7 @@ python-jose[cryptography]==3.3.0
# Task queue
celery[redis]==5.4.0
redis==5.2.1
redis==4.6.0
# AI/ML
faster-whisper==1.1.0
@@ -36,10 +36,10 @@ markdown==3.7
# Utils
ffmpeg-python==0.2.0
httpx==0.28.1
httpx>=0.23.0,<0.28.0
aiofiles==24.1.0
# Testing
pytest==8.3.4
pytest-asyncio==0.25.0
httpx==0.28.1
httpx>=0.23.0,<0.28.0