- core/auth.py: API Key auth via header X-API-Key (env PDFTOOLKIT_API_KEY) - Modo dev: sem chave configurada → acesso livre - Modo produção: exige chave, retorna 401/403 - api.py: endpoints protegidos com Depends(_auth_required) - /health e / permanecem públicos - Dockerfile: multi-stage (base → api → web) - docker-compose.yml: api + web com healthcheck, volumes e rede - .env.example: template de variáveis de ambiente - README.md: seções de autenticação e Docker
58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
services:
|
|
|
|
# ── API REST (FastAPI) ──────────────────────────────────────────
|
|
api:
|
|
build:
|
|
context: .
|
|
target: api
|
|
container_name: pdf-toolkit-api
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${API_PORT:-8555}:8555"
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- PDFTOOLKIT_API_KEY=${PDFTOOLKIT_API_KEY:-}
|
|
volumes:
|
|
- uploads:/tmp/uploads
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import http.client; conn=http.client.HTTPConnection('localhost:8555'); conn.request('GET','/health'); r=conn.getresponse(); exit(0 if r.status==200 else 1)"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
networks:
|
|
- pdf-net
|
|
|
|
# ── Interface Web (Streamlit) ───────────────────────────────────
|
|
web:
|
|
build:
|
|
context: .
|
|
target: web
|
|
container_name: pdf-toolkit-web
|
|
restart: unless-stopped
|
|
ports:
|
|
- "${WEB_PORT:-8550}:8550"
|
|
depends_on:
|
|
- api
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
- API_BASE_URL=http://api:8555
|
|
volumes:
|
|
- uploads:/tmp/uploads
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import http.client; conn=http.client.HTTPConnection('localhost:8550'); conn.request('GET','/'); r=conn.getresponse(); exit(0 if r.status==200 else 1)"]
|
|
interval: 30s
|
|
timeout: 5s
|
|
retries: 3
|
|
start_period: 10s
|
|
networks:
|
|
- pdf-net
|
|
|
|
volumes:
|
|
uploads:
|
|
|
|
networks:
|
|
pdf-net:
|
|
driver: bridge |