Use external DB/Redis in compose and preserve auth session across rebuilds
This commit is contained in:
@@ -24,6 +24,7 @@ OPENAI_MODEL="gpt-4o-mini"
|
|||||||
CF_AGENT_MODE="langgraph"
|
CF_AGENT_MODE="langgraph"
|
||||||
CF_WHISPER_MODEL="Xenova/whisper-small"
|
CF_WHISPER_MODEL="Xenova/whisper-small"
|
||||||
CF_WHISPER_LANGUAGE="ru"
|
CF_WHISPER_LANGUAGE="ru"
|
||||||
|
CF_RUN_SEED_ON_START="0"
|
||||||
|
|
||||||
TELEGRAM_BOT_TOKEN=""
|
TELEGRAM_BOT_TOKEN=""
|
||||||
TELEGRAM_WEBHOOK_SECRET=""
|
TELEGRAM_WEBHOOK_SECRET=""
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ done
|
|||||||
|
|
||||||
npx prisma db push
|
npx prisma db push
|
||||||
|
|
||||||
node prisma/seed.mjs
|
if [ "${CF_RUN_SEED_ON_START:-0}" = "1" ]; then
|
||||||
|
node prisma/seed.mjs
|
||||||
|
fi
|
||||||
|
|
||||||
exec npm run dev -- --host 0.0.0.0 --port 3000
|
exec npm run dev -- --host 0.0.0.0 --port 3000
|
||||||
|
|||||||
@@ -69,7 +69,24 @@ export async function getAuthContext(event: H3Event): Promise<AuthContext> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!conv) {
|
if (!conv) {
|
||||||
throw createError({ statusCode: 401, statusMessage: "Unauthorized" });
|
// Recover from stale conversation cookie after rebuild/reset:
|
||||||
|
// reuse latest available conversation (or recreate default one) and refresh cookie.
|
||||||
|
const fallback =
|
||||||
|
(await prisma.chatConversation.findFirst({
|
||||||
|
where: { teamId: team.id, createdByUserId: user.id },
|
||||||
|
orderBy: { updatedAt: "desc" },
|
||||||
|
})) ||
|
||||||
|
(await prisma.chatConversation.create({
|
||||||
|
data: { id: `pilot-${team.id}`, teamId: team.id, createdByUserId: user.id, title: "Pilot" },
|
||||||
|
}));
|
||||||
|
|
||||||
|
setSession(event, {
|
||||||
|
teamId: team.id,
|
||||||
|
userId: user.id,
|
||||||
|
conversationId: fallback.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return { teamId: team.id, userId: user.id, conversationId: fallback.id };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { teamId: team.id, userId: user.id, conversationId: conv.id };
|
return { teamId: team.id, userId: user.id, conversationId: conv.id };
|
||||||
|
|||||||
@@ -3,18 +3,12 @@ services:
|
|||||||
image: node:22-bookworm-slim
|
image: node:22-bookworm-slim
|
||||||
working_dir: /app/Frontend
|
working_dir: /app/Frontend
|
||||||
volumes:
|
volumes:
|
||||||
# Mount only the app source; keep node_modules inside the container to avoid
|
|
||||||
# leaking absolute host paths into Nuxt/Nitro dev runtime.
|
|
||||||
- ./Frontend:/app/Frontend
|
- ./Frontend:/app/Frontend
|
||||||
- clientsflow_data:/app/.data
|
|
||||||
- frontend_node_modules:/app/Frontend/node_modules
|
|
||||||
- frontend_nuxt:/app/Frontend/.nuxt
|
|
||||||
- frontend_output:/app/Frontend/.output
|
|
||||||
expose:
|
expose:
|
||||||
- "3000"
|
- "3000"
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/clientsflow?schema=public"
|
DATABASE_URL: "${DATABASE_URL:-postgresql://postgres:dpb6gmj1umjhohso@crm-sql-q57r8m:5432/postgres?schema=public}"
|
||||||
REDIS_URL: "redis://redis:6379"
|
REDIS_URL: "${REDIS_URL:-redis://default:nw0mv1pemhnbh7gw@crm-redis-vkpxku:6379}"
|
||||||
CF_AGENT_MODE: "langgraph"
|
CF_AGENT_MODE: "langgraph"
|
||||||
OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:-}"
|
OPENROUTER_API_KEY: "${OPENROUTER_API_KEY:-}"
|
||||||
OPENROUTER_BASE_URL: "https://openrouter.ai/api/v1"
|
OPENROUTER_BASE_URL: "https://openrouter.ai/api/v1"
|
||||||
@@ -24,6 +18,7 @@ services:
|
|||||||
OPENROUTER_REASONING_ENABLED: "${OPENROUTER_REASONING_ENABLED:-1}"
|
OPENROUTER_REASONING_ENABLED: "${OPENROUTER_REASONING_ENABLED:-1}"
|
||||||
CF_WHISPER_MODEL: "${CF_WHISPER_MODEL:-Xenova/whisper-small}"
|
CF_WHISPER_MODEL: "${CF_WHISPER_MODEL:-Xenova/whisper-small}"
|
||||||
CF_WHISPER_LANGUAGE: "${CF_WHISPER_LANGUAGE:-ru}"
|
CF_WHISPER_LANGUAGE: "${CF_WHISPER_LANGUAGE:-ru}"
|
||||||
|
CF_RUN_SEED_ON_START: "${CF_RUN_SEED_ON_START:-0}"
|
||||||
LANGFUSE_ENABLED: "${LANGFUSE_ENABLED:-true}"
|
LANGFUSE_ENABLED: "${LANGFUSE_ENABLED:-true}"
|
||||||
LANGFUSE_BASE_URL: "${LANGFUSE_BASE_URL:-http://langfuse-web:3000}"
|
LANGFUSE_BASE_URL: "${LANGFUSE_BASE_URL:-http://langfuse-web:3000}"
|
||||||
LANGFUSE_PUBLIC_KEY: "${LANGFUSE_PUBLIC_KEY:-pk-lf-local}"
|
LANGFUSE_PUBLIC_KEY: "${LANGFUSE_PUBLIC_KEY:-pk-lf-local}"
|
||||||
@@ -36,47 +31,28 @@ services:
|
|||||||
./scripts/compose-dev.sh
|
./scripts/compose-dev.sh
|
||||||
"
|
"
|
||||||
depends_on:
|
depends_on:
|
||||||
- redis
|
|
||||||
- postgres
|
|
||||||
- langfuse-web
|
- langfuse-web
|
||||||
|
networks:
|
||||||
|
- default
|
||||||
|
- dokploy-network
|
||||||
|
|
||||||
delivery-worker:
|
delivery-worker:
|
||||||
image: node:22-bookworm-slim
|
image: node:22-bookworm-slim
|
||||||
working_dir: /app/Frontend
|
working_dir: /app/Frontend
|
||||||
volumes:
|
volumes:
|
||||||
- ./Frontend:/app/Frontend
|
- ./Frontend:/app/Frontend
|
||||||
- clientsflow_data:/app/.data
|
|
||||||
- delivery_node_modules:/app/Frontend/node_modules
|
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/clientsflow?schema=public"
|
DATABASE_URL: "${DATABASE_URL:-postgresql://postgres:dpb6gmj1umjhohso@crm-sql-q57r8m:5432/postgres?schema=public}"
|
||||||
REDIS_URL: "redis://redis:6379"
|
REDIS_URL: "${REDIS_URL:-redis://default:nw0mv1pemhnbh7gw@crm-redis-vkpxku:6379}"
|
||||||
TELEGRAM_API_BASE: "${TELEGRAM_API_BASE:-https://api.telegram.org}"
|
TELEGRAM_API_BASE: "${TELEGRAM_API_BASE:-https://api.telegram.org}"
|
||||||
TELEGRAM_BOT_TOKEN: "${TELEGRAM_BOT_TOKEN:-}"
|
TELEGRAM_BOT_TOKEN: "${TELEGRAM_BOT_TOKEN:-}"
|
||||||
command: >
|
command: >
|
||||||
bash -lc "
|
bash -lc "
|
||||||
bash ./scripts/compose-worker.sh
|
bash ./scripts/compose-worker.sh
|
||||||
"
|
"
|
||||||
depends_on:
|
networks:
|
||||||
- redis
|
- default
|
||||||
- postgres
|
- dokploy-network
|
||||||
|
|
||||||
redis:
|
|
||||||
image: redis:7-alpine
|
|
||||||
expose:
|
|
||||||
- "6379"
|
|
||||||
volumes:
|
|
||||||
- redis_data:/data
|
|
||||||
|
|
||||||
postgres:
|
|
||||||
image: postgres:16-alpine
|
|
||||||
expose:
|
|
||||||
- "5432"
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: "clientsflow"
|
|
||||||
POSTGRES_USER: "postgres"
|
|
||||||
POSTGRES_PASSWORD: "postgres"
|
|
||||||
volumes:
|
|
||||||
- postgres_data:/var/lib/postgresql/data
|
|
||||||
|
|
||||||
langfuse-worker:
|
langfuse-worker:
|
||||||
image: docker.io/langfuse/langfuse-worker:3
|
image: docker.io/langfuse/langfuse-worker:3
|
||||||
@@ -210,14 +186,11 @@ services:
|
|||||||
start_period: 5s
|
start_period: 5s
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
clientsflow_data:
|
|
||||||
frontend_node_modules:
|
|
||||||
delivery_node_modules:
|
|
||||||
frontend_nuxt:
|
|
||||||
frontend_output:
|
|
||||||
redis_data:
|
|
||||||
postgres_data:
|
|
||||||
langfuse_postgres_data:
|
langfuse_postgres_data:
|
||||||
langfuse_clickhouse_data:
|
langfuse_clickhouse_data:
|
||||||
langfuse_clickhouse_logs:
|
langfuse_clickhouse_logs:
|
||||||
langfuse_minio_data:
|
langfuse_minio_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
dokploy-network:
|
||||||
|
external: true
|
||||||
|
|||||||
Reference in New Issue
Block a user