caarleexx commited on
Commit
0c148f6
·
verified ·
1 Parent(s): f5104ba

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -60
Dockerfile CHANGED
@@ -1,83 +1,49 @@
1
  # ============================================================================
2
- # Dockerfile para Hugging Face Spaces - para.AI API v3.0
3
- # Com PostgreSQL temporário embutido (CORRIGIDO para Debian Bookworm)
 
 
 
 
 
4
  # ============================================================================
5
 
6
  FROM python:3.11-slim
7
 
8
- # Metadados
9
  LABEL maintainer="para.AI Team"
10
- LABEL version="3.0.0"
11
- LABEL description="API de análise jurisprudencial com IA + PostgreSQL local"
12
 
13
  # Variáveis de ambiente
14
  ENV PYTHONUNBUFFERED=1 \
15
  PYTHONDONTWRITEBYTECODE=1 \
16
  PIP_NO_CACHE_DIR=1 \
17
- PIP_DISABLE_PIP_VERSION_CHECK=1 \
18
  DEBIAN_FRONTEND=noninteractive
19
 
20
- # Definir diretório de trabalho
21
  WORKDIR /app
22
 
23
  # ============================================================================
24
- # ADICIONAR REPOSITÓRIO DO POSTGRESQL + INSTALAR DEPENDÊNCIAS
25
  # ============================================================================
26
- RUN apt-get update && apt-get install -y \
27
- # Ferramentas básicas
28
- curl \
29
- wget \
30
- gnupg \
31
- lsb-release \
32
- && \
33
- # Adicionar repositório oficial do PostgreSQL
34
- echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
35
- wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
36
- # Atualizar e instalar PostgreSQL
37
- apt-get update && apt-get install -y \
38
- # Build essentials
39
  gcc \
40
- g++ \
41
- make \
42
- # PostgreSQL 15
43
- postgresql-15 \
44
- postgresql-client-15 \
45
- postgresql-contrib-15 \
46
- # Utilities
47
- procps \
48
- && \
49
- # Limpar cache
50
- rm -rf /var/lib/apt/lists/*
51
-
52
- # ============================================================================
53
- # CONFIGURAR POSTGRESQL
54
- # ============================================================================
55
- # Criar diretórios para PostgreSQL
56
- RUN mkdir -p /var/lib/postgresql/data \
57
- /var/run/postgresql \
58
- /var/log/postgresql \
59
- && chmod 2777 /var/run/postgresql
60
 
61
  # ============================================================================
62
  # INSTALAR DEPENDÊNCIAS PYTHON
63
  # ============================================================================
64
  COPY requirements.txt .
65
- RUN pip install --no-cache-dir -r requirements.txt
 
66
 
67
  # ============================================================================
68
- # COPIAR CÓDIGO DA APLICAÇÃO
69
  # ============================================================================
70
  COPY . .
71
 
72
  # ============================================================================
73
- # COPIAR E PREPARAR SCRIPTS
74
- # ============================================================================
75
- COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
76
- COPY scripts/init-postgres.sh /init-postgres.sh
77
- RUN chmod +x /docker-entrypoint.sh /init-postgres.sh
78
-
79
- # ============================================================================
80
- # CRIAR DIRETÓRIOS DA APLICAÇÃO
81
  # ============================================================================
82
  RUN mkdir -p /app/data/uploads \
83
  /app/data/outputs \
@@ -87,27 +53,23 @@ RUN mkdir -p /app/data/uploads \
87
  && chmod -R 755 /app
88
 
89
  # ============================================================================
90
- # CONFIGURAÇÕES PADRÃO
91
  # ============================================================================
92
  ENV APP_ENV=production \
93
  HOST=0.0.0.0 \
94
  PORT=7860 \
95
- DATABASE_URL=postgresql://para_ai:para_ai_temp@localhost:5432/para_ai \
96
- POSTGRES_USER=para_ai \
97
- POSTGRES_PASSWORD=para_ai_temp \
98
- POSTGRES_DB=para_ai
99
 
100
  # ============================================================================
101
  # HEALTH CHECK
102
  # ============================================================================
103
- HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
104
  CMD curl -f http://localhost:7860/api/v1/health || exit 1
105
 
106
- # Expor portas
107
  EXPOSE 7860
108
 
109
  # ============================================================================
110
- # ENTRYPOINT
111
  # ============================================================================
112
- ENTRYPOINT ["/docker-entrypoint.sh"]
113
  CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
 
1
  # ============================================================================
2
+ # Dockerfile ALTERNATIVO - para.AI API v3.0 (SQLite para testes rápidos)
3
+ # Imagem MUITO mais leve (~300MB vs 800MB)
4
+ # ============================================================================
5
+ #
6
+ # ATENÇÃO: Esta versão usa SQLite para testes rápidos
7
+ # Para produção, use Dockerfile principal com PostgreSQL
8
+ #
9
  # ============================================================================
10
 
11
  FROM python:3.11-slim
12
 
 
13
  LABEL maintainer="para.AI Team"
14
+ LABEL version="3.0.0-lite"
15
+ LABEL description="API de análise jurisprudencial (versão leve com SQLite)"
16
 
17
  # Variáveis de ambiente
18
  ENV PYTHONUNBUFFERED=1 \
19
  PYTHONDONTWRITEBYTECODE=1 \
20
  PIP_NO_CACHE_DIR=1 \
 
21
  DEBIAN_FRONTEND=noninteractive
22
 
 
23
  WORKDIR /app
24
 
25
  # ============================================================================
26
+ # INSTALAR DEPENDÊNCIAS MÍNIMAS DO SISTEMA
27
  # ============================================================================
28
+ RUN apt-get update && apt-get install -y --no-install-recommends \
 
 
 
 
 
 
 
 
 
 
 
 
29
  gcc \
30
+ curl \
31
+ && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  # ============================================================================
34
  # INSTALAR DEPENDÊNCIAS PYTHON
35
  # ============================================================================
36
  COPY requirements.txt .
37
+ RUN pip install --no-cache-dir -r requirements.txt && \
38
+ pip install --no-cache-dir aiosqlite
39
 
40
  # ============================================================================
41
+ # COPIAR CÓDIGO
42
  # ============================================================================
43
  COPY . .
44
 
45
  # ============================================================================
46
+ # CRIAR DIRETÓRIOS
 
 
 
 
 
 
 
47
  # ============================================================================
48
  RUN mkdir -p /app/data/uploads \
49
  /app/data/outputs \
 
53
  && chmod -R 755 /app
54
 
55
  # ============================================================================
56
+ # CONFIGURAÇÕES (SQLite)
57
  # ============================================================================
58
  ENV APP_ENV=production \
59
  HOST=0.0.0.0 \
60
  PORT=7860 \
61
+ DATABASE_URL=sqlite:///app/data/para_ai.db \
62
+ SQLITE_MODE=true
 
 
63
 
64
  # ============================================================================
65
  # HEALTH CHECK
66
  # ============================================================================
67
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
68
  CMD curl -f http://localhost:7860/api/v1/health || exit 1
69
 
 
70
  EXPOSE 7860
71
 
72
  # ============================================================================
73
+ # COMANDO
74
  # ============================================================================
 
75
  CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]