Skip to content

Deployment

Your Name edited this page Jul 11, 2026 · 2 revisions

🚀 Deploy e Implantação

Docker

# Build da imagem
docker build -t projeto-oms .

# Executar CI dentro do container
docker run --rm projeto-oms make ci

Dockerfile

Imagem leve baseada em python:3.12-slim-bookworm com:

  • dbt-core + dbt-duckdb
  • Streamlit + Plotly
  • Scripts de init e health check
flowchart LR
    A[Dockerfile] -->|FROM python:3.12-slim| B[deps stage]
    B -->|pip install| C[requirements.txt]
    C -->|COPY| D[runtime stage]
    D -->|CMD| E[make build]
Loading

CI/CD — GitHub Actions

Workflow (6 gates)

flowchart LR
    A[push / PR] --> B[Checkout]
    B --> C[Setup Python 3.12]
    C --> D[pip install]
    D --> E[init_test_db]
    E --> F[dbt deps]
    F --> G[dbt build<br/>49 steps]
    G --> H[health_check]
    H --> I[reconciliation<br/>--ci 0.1%]
    I --> J[data_contracts<br/>--ci]
    J --> K[lineage_report<br/>--format json]
    K --> L{Status}
    L -->|pass| M[✅ CI verde]
    L -->|fail| N[❌ GitHub email]
    M --> O[⬆ Upload artifacts]
    N --> O
Loading

Gatilhos

Gatilhos

  • push para main / master
  • pull_request para main / master
  • Ignora: **.md, .gitignore

Quality Gates (pós-build)

Após o dbt build, o CI executa 3 gates de qualidade em sequência:

  1. health_check — existência dos bancos, integridade referencial, freshness
  2. reconciliation --ci — raw vs staging vs marts (volume, uniqueness, soma, tolerância 0.1%)
  3. data_contracts --ci — schema, tipos, nulabilidade, PK uniqueness
  4. lineage_report --format json — extração da linhagem do manifest.json

Se qualquer gate falhar:

  • CI fica vermelho
  • GitHub notifica por email com link para os logs
  • Artefatos (compiled SQL, run_results) são preservados para diagnóstico

Agendamento

Opção 1: Cron (leve)

# Execução manual
bash scripts/scheduler.sh

# Crontab (diário às 8h)
0 8 * * * /path/to/scripts/scheduler.sh >> /path/to/logs/scheduler.log 2>&1

Opção 2: Apache Airflow

pip install apache-airflow
export AIRFLOW_HOME=$(pwd)/airflow
mkdir -p $AIRFLOW_HOME/dags
ln -s $(pwd)/dags/oms_data_pipeline.py $AIRFLOW_HOME/dags/
airflow standalone

A DAG oms_data_pipeline executa em 3 tasks:

flowchart LR
    A[check_raw_db] --> B[dbt_build]
    B --> C[health_check]
Loading

Makefile Targets

Comando Descrição
make setup Virtualenv + dependências + pacotes dbt
make build dbt build (modelos + testes)
make test dbt test (apenas testes)
make run dbt run (apenas modelos)
make ci CI completo (banco de teste + clean + build)
make clean Limpa artefatos dbt e DuckDB
make health Health check completo
make contracts Validação de contratos de dados
make reconcile Reconciliação cross-camada
make lineage Relatório de linhagem
make dashboard Streamlit Dashboard
make schedule Pipeline agendado
make shell DuckDB shell

Clone this wiki locally