core/repo-integrations-core/REPO-INTEGRATIONS-CORE.md
Tiago Yamamoto a52bd4519d refactor: optimize Dockerfiles and documentation for core services
- Use Google Distroless images for all services (Go & Node.js).
- Standardize documentation with [PROJECT-NAME].md.
- Add .dockerignore and .gitignore to all projects.
- Remove docker-compose.yml in favor of docker run instructions.
- Fix Go version and dependency issues in observability, repo-integrations, and security-governance.
- Add Podman support (fully qualified image names).
- Update Dashboard to use Node.js static server for Distroless compatibility.
2025-12-30 13:22:34 -03:00

73 lines
2 KiB
Markdown

# REPO-INTEGRATIONS-CORE
O `repo-integrations-core` é o serviço responsável por gerenciar o ciclo de vida de integrações com provedores de controle de versão (Git).
## 📋 Visão Geral
Este serviço atua como um middleware inteligente entre a plataforma e provedores externos (GitHub, GitLab, Bitbucket), normalizando fluxos de autenticação (OAuth) e ingestão de eventos (Webhooks).
### Arquitetura
```mermaid
graph LR
User[Usuário] -->|OAuth Flow| API[Repo Integrations]
API -->|Exchange Code| GitHub[GitHub API]
API -->|Store Token| DB[(Encrypted DB)]
GitHub -->|Webhook| API
API -->|Normalize| EventBus[Event Bus / Queue]
```
## 🚀 Estrutura do Projeto
O projeto é escrito em **Go** e estrutura-se da seguinte forma:
| Diretório | Descrição |
| :--- | :--- |
| `cmd/api` | Entrypoint. |
| `internal/oauth` | Fluxos de autenticação. |
| `internal/webhooks` | Processamento e validação de webhooks. |
| `internal/provider` | Abstrações para diferentes providers (GitHub, GitLab). |
## 🛠️ Tecnologias e Otimizações
- **Linguagem**: Go 1.23.
- **Database**: PostgreSQL (tokens criptografados).
- **Segurança**: Criptografia AES-GCM para tokens de acesso.
- **Containerização**:
- Base `gcr.io/distroless/static:nonroot`.
- Build estático.
## 💻 Como Executar
### Docker (Recomendado)
```bash
# Build
docker build -t repo-integrations-core .
# Run
docker run -p 8080:8080 --env-file .env repo-integrations-core
```
Disponível na porta `8080`.
### Desenvolvimento
1. **Setup**:
```bash
cp .env.example .env
go mod tidy
```
2. **App GitHub**: Você precisará criar um GitHub App e configurar `GITHUB_CLIENT_ID` e `GITHUB_SECRET`.
3. **Executar**:
```bash
go run ./cmd/api
```
## 🔧 Detalhes do Dockerfile
O `Dockerfile` segue o padrão de otimização da plataforma:
- **Builder**: `golang:1.23-alpine`.
- **Runtime**: `distroless/static` (sem shell, non-root).
- **Compilação**: Flags `-w -s` para redução de binário.