caarleexx commited on
Commit
fc223f6
·
verified ·
1 Parent(s): 7bda30a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -9
Dockerfile CHANGED
@@ -1,9 +1,7 @@
1
  FROM node:20-slim
2
  WORKDIR /app
3
 
4
- # 1. Instala Git
5
- RUN apt-get update && apt-get install -y git
6
-
7
  RUN apt-get update && apt-get install -y git libcurl4
8
 
9
  # 2. Clona o repositório
@@ -15,8 +13,7 @@ COPY .env .
15
  # 4. Instala Dependências
16
  RUN npm ci
17
 
18
- # 5. Cria um arquivo adaptador para corrigir o erro do MongoDB na memória
19
- # Isso injeta a variável __dirname que está faltando
20
  RUN printf "import { fileURLToPath } from 'url';\n\
21
  import { dirname } from 'path';\n\
22
  const __filename = fileURLToPath(import.meta.url);\n\
@@ -29,14 +26,15 @@ import('./build/index.js');" > adapter.js
29
  ENV OPENAI_BASE_URL="https://api.groq.com/openai/v1"
30
  ENV NODE_OPTIONS="--max-old-space-size=4096"
31
 
32
- # 7. Executa o Build (usando a chave injetada)
33
  RUN OPENAI_API_KEY=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 npm run build
34
 
35
  # 8. Configuração de Execução
36
  ENV NODE_OPTIONS=""
37
  ENV PORT=7860
38
- ENV ORIGIN="https://huggingface.co"
39
  EXPOSE 7860
40
 
41
- # 9. Inicia usando o nosso adaptador em vez do arquivo direto
42
- CMD ["sh", "-c", "OPENAI_API_KEY=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 node adapter.js"]
 
 
1
  FROM node:20-slim
2
  WORKDIR /app
3
 
4
+ # 1. Instala Git e libcurl
 
 
5
  RUN apt-get update && apt-get install -y git libcurl4
6
 
7
  # 2. Clona o repositório
 
13
  # 4. Instala Dependências
14
  RUN npm ci
15
 
16
+ # 5. Adaptador do Banco de Dados
 
17
  RUN printf "import { fileURLToPath } from 'url';\n\
18
  import { dirname } from 'path';\n\
19
  const __filename = fileURLToPath(import.meta.url);\n\
 
26
  ENV OPENAI_BASE_URL="https://api.groq.com/openai/v1"
27
  ENV NODE_OPTIONS="--max-old-space-size=4096"
28
 
29
+ # 7. Build
30
  RUN OPENAI_API_KEY=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 npm run build
31
 
32
  # 8. Configuração de Execução
33
  ENV NODE_OPTIONS=""
34
  ENV PORT=7860
35
+ # Removemos a linha fixa do ORIGIN daqui para colocar no comando final
36
  EXPOSE 7860
37
 
38
+ # 9. INICIALIZAÇÃO INTELIGENTE
39
+ # Usamos a variável SPACE_HOST que o Hugging Face fornece para configurar o ORIGIN automaticamente.
40
+ CMD ["sh", "-c", "ORIGIN=https://$SPACE_HOST OPENAI_API_KEY=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 node adapter.js"]