-
Notifications
You must be signed in to change notification settings - Fork 70
Improve Docker and Dev #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
316b613
ac4cbde
ae833b3
62e8ac4
1920296
2c6db58
3917c7e
df43ffd
e7e6442
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||||||||||||||||||||||||||||||||||||||
| # Desenvolvimento — deepsproxy | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Este documento descreve como subir o ambiente de desenvolvimento, rodar testes que reaproveitam a sessão do navegador, inspecionar logs e exemplos de requisições. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| 1) Subir o ambiente de desenvolvimento | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - Usando o helper `dev.sh` (recomendado): | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| ./dev.sh up | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Para trazer os containers e seguir logs do Playwright: | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| ./dev.sh logs | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Observações: | ||||||||||||||||||||||||||||||||||||||||||
| - `dev.sh` usa `docker-compose.yml` e `docker-compose.dev.yml` como override. | ||||||||||||||||||||||||||||||||||||||||||
| - O ambiente dev pode usar `network_mode: host` (visibilidade do X11) — se estiver ativo, os mapeamentos de porta não aparecem no `docker ps`, mas a API está acessível em `http://localhost:$PORT` (veja `.env`). | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| 2) Rodar testes de desenvolvimento aproveitando a sessão existente | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - O teste que reaproveita a sessão atual foi criado em `src/current_session.test.ts`. | ||||||||||||||||||||||||||||||||||||||||||
| - Para executá-lo dentro do container que tem a sessão do Playwright montada (não inicie um novo navegador): | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| docker exec -i deepsproxy sh -c 'cd /app && timeout 20s env RUN_REAL_BROWSER_TESTS=1 PLAYWRIGHT_HEADLESS=false npx tsx --test src/current_session.test.ts' | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - Explicação: | ||||||||||||||||||||||||||||||||||||||||||
| - `RUN_REAL_BROWSER_TESTS=1` habilita o teste que exige uma sessão real. | ||||||||||||||||||||||||||||||||||||||||||
| - `PLAYWRIGHT_HEADLESS=false` garante que o navegador rode em modo headed se necessário. | ||||||||||||||||||||||||||||||||||||||||||
| - O comando assume que `deepsproxy-playwright` já está em execução e que `./deepseek_profile` está montado no container (para reaproveitar login). | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| 3) Verificar logs de ambos os containers | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - Logs do serviço Playwright (útil para ver inicialização do navegador e erros de Playwright): | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| docker logs -f deepsproxy-playwright | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - Logs da API (deepsproxy): | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| docker logs -f deepsproxy | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| 4) Diagrama de comunicação (Mermaid) | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```mermaid | ||||||||||||||||||||||||||||||||||||||||||
| sequenceDiagram | ||||||||||||||||||||||||||||||||||||||||||
| participant Client as Cliente (curl / browser) | ||||||||||||||||||||||||||||||||||||||||||
| participant API as deepsproxy (API) | ||||||||||||||||||||||||||||||||||||||||||
| participant PW as Playwright Service | ||||||||||||||||||||||||||||||||||||||||||
| participant DS as deepseek.com | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Client->>API: POST /v1/chat/completions (JSON) | ||||||||||||||||||||||||||||||||||||||||||
| API->>PW: requisita headers/session (PLAYWRIGHT_REMOTE_URL) | ||||||||||||||||||||||||||||||||||||||||||
| PW->>DS: faz requisições web automatizadas usando perfil (deepseek_profile) | ||||||||||||||||||||||||||||||||||||||||||
| DS-->>PW: resposta (cookies, tokens, SSE) | ||||||||||||||||||||||||||||||||||||||||||
| PW-->>API: headers e/ou stream | ||||||||||||||||||||||||||||||||||||||||||
| API-->>Client: resposta agregada (SSE ou JSON) | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| 5) Exemplo de `curl` pedindo os presidentes do Brasil (2000–2025) em JSON curto | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Observação: o `PORT` padrão do projeto é definido no arquivo `.env` (ex.: `PORT=9300`). Substitua se necessário. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| ```bash | ||||||||||||||||||||||||||||||||||||||||||
| curl -s -X POST http://localhost:9300/v1/chat/completions \ | ||||||||||||||||||||||||||||||||||||||||||
| -H 'Content-Type: application/json' \ | ||||||||||||||||||||||||||||||||||||||||||
| -d '{ | ||||||||||||||||||||||||||||||||||||||||||
| "model":"deepseek-thinking", | ||||||||||||||||||||||||||||||||||||||||||
| "messages":[{"role":"user","content":"Retorne SOMENTE em JSON compacto a lista dos presidentes do Brasil entre 2000 e 2025, no formato [{\"inicio_mandato\":2000,\"nome\":\"Nome\"}, ...] — inclua só ano e nome, respostas curtas."}], | ||||||||||||||||||||||||||||||||||||||||||
| "stream":false | ||||||||||||||||||||||||||||||||||||||||||
| }' | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Exemplo de saída esperada (apenas referência): | ||||||||||||||||||||||||||||||||||||||||||
| #{"presidentes":[{"ano":2003,"nome":"Luiz Inácio Lula da Silva"},{"ano":2011,"nome":"Dilma Rousseff"},{"ano":2016,"nome":"Michel Temer"}]} | ||||||||||||||||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix sample output to match the prompt contract and timeframe. The prompt asks for presidents from 2000 to 2025 with Suggested doc fix-# Exemplo de saída esperada (apenas referência):
-#{"presidentes":[{"ano":2003,"nome":"Luiz Inácio Lula da Silva"},{"ano":2011,"nome":"Dilma Rousseff"},{"ano":2016,"nome":"Michel Temer"}]}
+# Exemplo de saída esperada (apenas referência):
+#{"presidentes":[
+# {"inicio_mandato":2000,"nome":"Fernando Henrique Cardoso"},
+# {"inicio_mandato":2003,"nome":"Luiz Inácio Lula da Silva"},
+# {"inicio_mandato":2011,"nome":"Dilma Rousseff"},
+# {"inicio_mandato":2016,"nome":"Michel Temer"},
+# {"inicio_mandato":2019,"nome":"Jair Bolsonaro"},
+# {"inicio_mandato":2023,"nome":"Luiz Inácio Lula da Silva"}
+#]}📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 68-68: Ordered list item prefix (MD029, ol-prefix) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Dicas rápidas | ||||||||||||||||||||||||||||||||||||||||||
| - Se o `curl` apontando para `localhost:$PORT` falhar, verifique: | ||||||||||||||||||||||||||||||||||||||||||
| - Se os containers estão up: `docker ps`. | ||||||||||||||||||||||||||||||||||||||||||
| - Se o compose dev usa `network_mode: host`: nesse caso a porta é do host (acessível em `localhost`). | ||||||||||||||||||||||||||||||||||||||||||
| - Logs: `docker logs deepsproxy` e `docker logs deepsproxy-playwright`. | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| Se quiser, posso adicionar checks automáticos ao `dev.sh` (ex.: aguardar healthcheck do Playwright, rodar `curl /health` da API) — quer que eu adicione isso? | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||||||||||||||||||||||||
| FROM node:20-slim AS builder | ||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||
| COPY package*.json ./ | ||||||||||||||||||||||||||||||||||||||||||
| RUN npm ci --production=false | ||||||||||||||||||||||||||||||||||||||||||
| COPY . . | ||||||||||||||||||||||||||||||||||||||||||
| RUN npm run build | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| FROM node:20-slim | ||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||
| COPY --from=builder /app/node_modules ./node_modules | ||||||||||||||||||||||||||||||||||||||||||
| COPY --from=builder /app/package*.json ./ | ||||||||||||||||||||||||||||||||||||||||||
| COPY --from=builder /app/dist ./dist | ||||||||||||||||||||||||||||||||||||||||||
| COPY --from=builder /app/src ./src | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prune dev dependencies from API runtime image. Current runtime copies builder Suggested fix FROM node:20-slim AS builder
@@
RUN npm ci --production=false
@@
FROM node:20-slim
WORKDIR /app
-COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
+RUN npm ci --omit=dev
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/src ./src📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| EXPOSE 3000 | ||||||||||||||||||||||||||||||||||||||||||
| CMD ["node", "dist/index.js"] | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run API container as non-root. The final API image runs as root; switch to an unprivileged user for baseline hardening. Suggested fix FROM node:20-slim
WORKDIR /app
@@
COPY --from=builder /app/src ./src
+RUN chown -R node:node /app
+USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]🧰 Tools🪛 Checkov (3.2.529)[low] 1-15: Ensure that HEALTHCHECK instructions have been added to container images (CKV_DOCKER_2) [low] 1-15: Ensure that a user for the container has been created (CKV_DOCKER_3) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| FROM node:20-slim AS builder | ||
| WORKDIR /app | ||
| COPY package*.json ./ | ||
| RUN npm ci | ||
| RUN npm ci --production=false | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Runtime image is likely shipping devDependencies.
Suggested fix FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --production=false
COPY . .
RUN npm run build
FROM node:20-slim
@@
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package*.json ./
+RUN npm prune --omit=devAlso applies to: 20-21 🤖 Prompt for AI Agents |
||
| COPY . . | ||
| RUN npm run build | ||
|
|
||
| FROM node:20-slim | ||
| RUN apt-get update && apt-get install -y \ | ||
| wget \ | ||
| gnupg \ | ||
| ca-certificates \ | ||
| && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ | ||
| && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list \ | ||
| && apt-get update && apt-get install -y google-chrome-stable \ | ||
|
|
@@ -17,8 +18,16 @@ ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | |
| ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 | ||
| WORKDIR /app | ||
| COPY --from=builder /app/node_modules ./node_modules | ||
| COPY --from=builder /app/dist ./dist | ||
| COPY --from=builder /app/package*.json ./ | ||
|
|
||
| # Install Playwright browsers before copying application artifacts that | ||
| # change frequently. This keeps the browser download layer cached across | ||
| # rebuilds when only source files change. | ||
| RUN npx playwright install chromium | ||
| EXPOSE 3000 | ||
| CMD ["node", "dist/index.js"] | ||
|
|
||
| # Now copy application artifacts (dist/src) last so code changes won't | ||
| # force re-downloading the browser. | ||
| COPY --from=builder /app/dist ./dist | ||
| COPY --from=builder /app/src ./src | ||
| EXPOSE 9301 | ||
| CMD ["node", "dist/playwright-service.js"] | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,104 @@ | ||||||||||||
| # LAST STATUS | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix markdown heading/code-fence spacing to satisfy MD022/MD031. Several headings and one fenced block are missing required blank lines before/after; this should be normalized to keep markdownlint clean. Also applies to: 6-6, 13-13, 18-18, 25-25, 31-31, 39-39, 58-58, 62-62, 65-66, 94-94, 99-99 🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 1-1: Headings should be surrounded by blank lines (MD022, blanks-around-headings) 🤖 Prompt for AI Agents |
||||||||||||
| Date: 2026-05-15 (atualizado após validação end-to-end com Nanobrowser) | ||||||||||||
|
|
||||||||||||
| ## Problemas identificados nos logs (15/05/2026) | ||||||||||||
|
|
||||||||||||
| ### Problema 1 — CRÍTICO (RESOLVIDO): Profile Singleton Lock | ||||||||||||
| - **Erro:** `process_singleton_posix.cc:363 — profile in use by another computer (3d53ce7583a9), exitCode=21` | ||||||||||||
| - **Causa:** Ao reiniciar o container, o Docker atribui um novo hostname. O arquivo `Singleton` do Chrome ficava para trás com PID + hostname do container anterior. O novo Chromium lia o lock de uma "máquina diferente" e recusava iniciar. | ||||||||||||
| - **Fix aplicado em `src/services/playwright.ts`:** | ||||||||||||
| - Função `clearProfileLocks()` que remove arquivos `Singleton*` antes de cada `launchPersistentContext`. | ||||||||||||
| - Try/catch no launch: se falhar com erro de "profile" ou "Singleton", limpa e faz um retry automático. | ||||||||||||
|
|
||||||||||||
| ### Problema 2 — CRÍTICO (RESOLVIDO): Cascata de retries sem cleanup | ||||||||||||
| - **Erro:** 3 chamadas seguidas a `launchPersistentContext` no playwright-service, todas falhando com o mesmo lock. | ||||||||||||
| - **Causa:** O `chat.ts` fazia retry no `createDeepSeekStream`, que chamava `/headers` no playwright-service, que tentava `launchPersistentContext` sem limpar locks entre tentativas. | ||||||||||||
| - **Fix:** O `clearProfileLocks` antes de cada launch garante que mesmo os retries externos agora funcionam. | ||||||||||||
|
|
||||||||||||
| ### Problema 3 — MÉDIO (RESOLVIDO): Browser não inicializado na subida | ||||||||||||
| - **Causa:** O `playwright-service.ts` só inicializava o browser sob demanda (na primeira chamada `/headers`). Qualquer requisição chegando antes disso falhava. | ||||||||||||
| - **Fix aplicado em `src/playwright-service.ts`:** | ||||||||||||
| - `initPlaywright()` é chamado na inicialização do serviço (eager init). | ||||||||||||
| - `/health` retorna HTTP 503 enquanto o browser não estiver pronto (`browserReady = false`). | ||||||||||||
| - Tratamento de SIGTERM adicionado ao playwright-service. | ||||||||||||
|
|
||||||||||||
| ### Problema 4 — MÉDIO (RESOLVIDO): Sem ordering entre containers | ||||||||||||
| - **Causa:** `deepsproxy` subia junto com `deepsproxy-playwright` sem esperar o browser estar pronto. | ||||||||||||
| - **Fix aplicado em `docker-compose.yml`:** | ||||||||||||
| - `healthcheck` no container `playwright`: `curl -sf http://localhost:9301/health` a cada 5s, até 10 tentativas, com `start_period: 30s`. | ||||||||||||
| - `depends_on` no container `deepsproxy` com `condition: service_healthy`. | ||||||||||||
|
|
||||||||||||
| ## Estado atual após fixes | ||||||||||||
| - Containers sobem em ordem: `playwright` → (healthy) → `deepsproxy`. | ||||||||||||
| - Locks do profile são limpos automaticamente no startup do `playwright-service`. | ||||||||||||
| - Recovery automático em caso de lock residual (retry após limpeza). | ||||||||||||
| - `/health` do playwright-service reflete o estado real do browser. | ||||||||||||
|
|
||||||||||||
| ## Checklist | ||||||||||||
|
|
||||||||||||
| ### ✅ Feito | ||||||||||||
| - [x] Singleton lock cleanup automático no startup do playwright-service | ||||||||||||
| - [x] Retry automático após falha de lock (clearProfileLocks + try/catch) | ||||||||||||
| - [x] Eager init do browser no playwright-service (não espera primeira requisição) | ||||||||||||
| - [x] `/health` do playwright-service reflete estado real do browser (`browserReady`) | ||||||||||||
| - [x] `docker-compose.dev.yml` com `network_mode: host` para acesso ao X11 do host | ||||||||||||
| - [x] `dev.sh` para subir em modo headed (browser visível na tela) | ||||||||||||
| - [x] Browser abrindo visível na tela do host com `./dev.sh` ✅ (confirmado 15/05) | ||||||||||||
| - [x] Sessão DeepSeek válida e carregada no browser ✅ | ||||||||||||
| - [x] API respondendo: `GET /health` → `{"status":"ok"}` em :9300 e :9301 ✅ | ||||||||||||
| - [x] `/chat/completions` e `/v1/chat/completions` ambos roteados ao handler ✅ | ||||||||||||
| - [x] `stream: false` retorna `application/json` correto (não SSE) ✅ | ||||||||||||
| - [x] `response_format: json_schema` / `json_object` → injeta instrução JSON no systemPrompt + schema ✅ | ||||||||||||
| - [x] Strip de tags `<think>...</think>` na resposta non-streaming ✅ | ||||||||||||
| - [x] Extração do bloco `{...}` do conteúdo quando `needsJson=true` ✅ | ||||||||||||
| - [x] Smart windowing: KEEP_HEAD=3 + KEEP_TAIL=4, MAX_PROMPT_CHARS=14000 ✅ | ||||||||||||
| - [x] `console.log` de debug: `[chat] model=... stream=... msgs=... promptLen=... needsJson=...` ✅ | ||||||||||||
| - [x] Fluxo end-to-end com Nanobrowser validado ✅ | ||||||||||||
|
|
||||||||||||
| ### ❌ Pendente / com problema | ||||||||||||
| - [ ] **Login automático** ainda não funciona (captcha na primeira sessão) — requer intervenção manual no browser headed. | ||||||||||||
| - [ ] Erro `Cannot convert undefined or null to object` no Navigator do Nanobrowser — pode ocorrer se o JSON retornado não for válido. Monitorar. | ||||||||||||
|
|
||||||||||||
| ## Próximo passo imediato | ||||||||||||
| Testar o fluxo completo do Nanobrowser com tarefas reais (navegar, analisar página, executar ações). | ||||||||||||
|
|
||||||||||||
| ## Comandos úteis | ||||||||||||
| ```bash | ||||||||||||
| # Subir em modo headed (browser visível) | ||||||||||||
| ./dev.sh logs | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+67
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the correct command for startup in headed mode. Line 68 currently tails logs instead of starting the environment. Under this heading, it should be Suggested doc fix # Subir em modo headed (browser visível)
-./dev.sh logs
+./dev.sh up📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| # Rebuild e subir produção | ||||||||||||
| docker compose build && docker compose up -d | ||||||||||||
|
|
||||||||||||
| # Acompanhar logs filtrados | ||||||||||||
| docker logs -f deepsproxy 2>&1 | grep -E "\[chat\]|GET |POST " | ||||||||||||
|
|
||||||||||||
| # Health check manual | ||||||||||||
| curl http://localhost:9301/health | ||||||||||||
| curl http://localhost:9300/health | ||||||||||||
|
|
||||||||||||
| # Limpar locks manualmente se necessário | ||||||||||||
| find deepseek_profile -name 'Singleton*' -delete | ||||||||||||
|
|
||||||||||||
| # Testar API non-streaming com json_schema | ||||||||||||
| curl -s http://localhost:9300/chat/completions \ | ||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||
| -d '{"model":"deepseek-no-thinking","messages":[{"role":"user","content":"Say hello"}],"stream":false,"response_format":{"type":"json_object"}}' | jq | ||||||||||||
|
|
||||||||||||
| # Testar API streaming | ||||||||||||
| curl -sS http://localhost:9300/v1/chat/completions \ | ||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||
| -d '{"model":"deepseek-thinking","messages":[{"role":"user","content":"Olá!"}],"stream":true}' | ||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| ## Próximos passos recomendados | ||||||||||||
| 1. Execute os comandos de verificação acima e cole a saída aqui (ou permita que eu a verifique). | ||||||||||||
| 2. Se `/tmp/.X11-unix` do host estiver montado e `xhost` autorizar o usuário, iniciar `docker compose up -d deepsproxy-playwright` e executar `docker exec -d -u node -e DISPLAY=$DISPLAY deepsproxy-playwright npm run login` (sem `xvfb-run`) para abrir o Chromium visível. | ||||||||||||
| 3. Se isso falhar, podemos: (a) ajustar montagem/permissões de `/tmp/.X11-unix` e `xauth`, ou (b) manter `xvfb-run` e usar VNC/novnc para ver a tela virtual. | ||||||||||||
|
|
||||||||||||
| ## Notas sobre validação com outros modelos/novo contexto | ||||||||||||
| - Para validar o comportamento em outro ambiente ou modelo, exporte `deepseek_profile` e rode Playwright localmente fora do container, ou reproduza em uma VM com X disponível. | ||||||||||||
| - Posso preparar um script curto que coleta logs, faz checagens e tenta ligar o browser no DISPLAY automaticamente (precisa de autorização para executar kills/changes). | ||||||||||||
|
|
||||||||||||
| --- | ||||||||||||
| Documento criado para iniciar um novo contexto de diagnóstico e validação. | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -329,7 +329,8 @@ deepsproxy/ | |
| │ ├── index.test.ts # Testes unitários básicos | ||
| │ └── advanced.test.ts # Testes de integração avançados | ||
| ├── docker-compose.yml # Orquestração multi-container | ||
| ├── Dockerfile # Imagem Docker otimizada | ||
| ├── Dockerfile.api # Dockerfile para a imagem da API | ||
| ├── Dockerfile.playwright # Dockerfile para o serviço Playwright | ||
|
Comment on lines
+332
to
+333
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align Docker usage examples with the split-image architecture. The project tree now documents 🤖 Prompt for AI Agents |
||
| ├── tsconfig.json # Configuração TypeScript strict | ||
| ├── package.json # Dependências e scripts | ||
| ├── .env.example # Template de variáveis de ambiente | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||
| # dev.sh — Sobe o deepsproxy em modo dev (headed browser visível na tela). | ||||||||||||||||||||||||||
| # Usa network_mode: host para acessar o X11 abstract socket do host. | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # Uso: | ||||||||||||||||||||||||||
| # ./dev.sh → sobe em background | ||||||||||||||||||||||||||
| # ./dev.sh rebuild → rebuilda ambas as imagens e sobe | ||||||||||||||||||||||||||
| # ./dev.sh logs → acompanha logs (api|browser|all) | ||||||||||||||||||||||||||
| # ./dev.sh down → para os containers | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win Enable strict Bash mode for safer script execution.
Suggested patch-set -e
+set -euo pipefail📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| CMD="${1:-up}" | ||||||||||||||||||||||||||
| TYPE="${2:-all}" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| case "$CMD" in | ||||||||||||||||||||||||||
| up) | ||||||||||||||||||||||||||
| docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d | ||||||||||||||||||||||||||
| echo "Para ver logs: ./dev.sh logs [api|browser|all]" | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| rebuild) | ||||||||||||||||||||||||||
| echo "Rebuilding all containers..." | ||||||||||||||||||||||||||
| docker rm -f deepsproxy deepsproxy-playwright || true | ||||||||||||||||||||||||||
| docker compose -f docker-compose.yml -f docker-compose.dev.yml build | ||||||||||||||||||||||||||
| docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d | ||||||||||||||||||||||||||
| echo "Para ver logs: ./dev.sh logs [api|browser|all]" | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| logs) | ||||||||||||||||||||||||||
| case "$TYPE" in | ||||||||||||||||||||||||||
| api) | ||||||||||||||||||||||||||
| docker logs -f deepsproxy | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| browser) | ||||||||||||||||||||||||||
| docker logs -f deepsproxy-playwright | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
|
Comment on lines
+30
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Suggested patch logs)
case "$TYPE" in
api)
- docker logs -f deepsproxy
+ docker compose -f docker-compose.yml -f docker-compose.dev.yml logs -f deepsproxy
;;
browser)
- docker logs -f deepsproxy-playwright
+ docker compose -f docker-compose.yml -f docker-compose.dev.yml logs -f deepsproxy-playwright
;;
*)
docker compose -f docker-compose.yml -f docker-compose.dev.yml logs -f
;;
esac📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| *) | ||||||||||||||||||||||||||
| docker compose -f docker-compose.yml -f docker-compose.dev.yml logs -f | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| down) | ||||||||||||||||||||||||||
| docker compose -f docker-compose.yml -f docker-compose.dev.yml down | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| *) | ||||||||||||||||||||||||||
| echo "Uso: ./dev.sh [up|rebuild|logs [api|browser|all]|down]" | ||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| services: | ||
| deepsproxy: | ||
| # network_mode: host | ||
| environment: | ||
| - PLAYWRIGHT_REMOTE_URL=http://playwright:9301 | ||
| volumes: | ||
| - ./src:/app/src:rw | ||
| playwright: | ||
| # network_mode: host | ||
| volumes: | ||
| - ./src:/app/src:rw | ||
| - ./deepseek_profile:/app/deepseek_profile:rw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve markdownlint ordered-list warnings (MD029).
These ordered list items should follow the configured style (
1.for each item) to avoid lint noise/failures.Also applies to: 23-23, 37-37, 51-51, 68-68
🤖 Prompt for AI Agents