From 98b79be03d42e301a7371727b06fb0474c3b51fb Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Mar 2026 12:05:39 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20Superset=20BI=20funcional=20=E2=80=94?= =?UTF-8?q?=20psycopg2,=20EMBEDDED=5FSUPERSET,=20gunicorn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.prod.yml | 23 +++++++++------------- docker/superset/Dockerfile | 5 +++++ docker/superset/init.sh | 23 ++++++++++++++++++++++ docker/superset/superset_config.py | 31 ++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 docker/superset/Dockerfile create mode 100755 docker/superset/init.sh create mode 100644 docker/superset/superset_config.py diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 2d8ec72..ea67982 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -234,27 +234,22 @@ services: # ── Superset BI ─────────────────────────────────────────────────────────────── superset: - image: apache/superset:latest + build: + context: ./docker/superset + dockerfile: Dockerfile restart: always environment: SUPERSET_SECRET_KEY: ${SUPERSET_SECRET_KEY} - SQLALCHEMY_DATABASE_URI: postgresql+psycopg2://${PGUSER:-arcadia}:${PGPASSWORD}@db:5432/superset - SUPERSET_LOAD_EXAMPLES: "no" + SQLALCHEMY_DATABASE_URI: postgresql://${PGUSER:-arcadia}:${PGPASSWORD}@db:5432/superset + PYTHONPATH: /app/pythonpath SUPERSET_ADMIN_USERNAME: ${SUPERSET_ADMIN_USERNAME:-admin} SUPERSET_ADMIN_PASSWORD: ${SUPERSET_ADMIN_PASSWORD} SUPERSET_ADMIN_EMAIL: ${SUPERSET_ADMIN_EMAIL:-admin@onboardbi.com.br} - command: > - /bin/sh -c " - superset db upgrade && - superset fab create-admin - --username \"$$SUPERSET_ADMIN_USERNAME\" - --firstname Arcadia --lastname Admin - --email \"$$SUPERSET_ADMIN_EMAIL\" - --password \"$$SUPERSET_ADMIN_PASSWORD\" || true && - superset init && - gunicorn --bind 0.0.0.0:8088 --workers 2 --timeout 120 'superset.app:create_app()' - " + ARCADIA_DATABASE_URL: postgresql+psycopg2://${PGUSER:-arcadia}:${PGPASSWORD}@db:5432/${PGDATABASE:-arcadia} + command: ["/bin/bash", "/app/docker/init.sh"] volumes: + - ./docker/superset/superset_config.py:/app/pythonpath/superset_config.py:ro + - ./docker/superset/init.sh:/app/docker/init.sh:ro - superset_home:/app/superset_home depends_on: db: diff --git a/docker/superset/Dockerfile b/docker/superset/Dockerfile new file mode 100644 index 0000000..923ddcf --- /dev/null +++ b/docker/superset/Dockerfile @@ -0,0 +1,5 @@ +FROM apache/superset:latest +USER root +RUN pip install psycopg2-binary && \ + sed -i 's/include-system-site-packages = false/include-system-site-packages = true/' /app/.venv/pyvenv.cfg +USER superset diff --git a/docker/superset/init.sh b/docker/superset/init.sh new file mode 100755 index 0000000..1448a39 --- /dev/null +++ b/docker/superset/init.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +echo "[Superset Init] Iniciando configuracao..." +superset db upgrade + +superset fab create-admin \ + --username "${SUPERSET_ADMIN_USERNAME:-admin}" \ + --firstname "Arcadia" \ + --lastname "Admin" \ + --email "${SUPERSET_ADMIN_EMAIL:-admin@onboardbi.com.br}" \ + --password "${SUPERSET_ADMIN_PASSWORD:-arcadia1337}" 2>/dev/null || true + +superset init + +echo "[Superset Init] Iniciando servidor..." +gunicorn \ + --bind "0.0.0.0:8088" \ + --access-logfile "-" \ + --error-logfile "-" \ + --workers 2 \ + --timeout 120 \ + "superset.app:create_app()" diff --git a/docker/superset/superset_config.py b/docker/superset/superset_config.py new file mode 100644 index 0000000..25233b5 --- /dev/null +++ b/docker/superset/superset_config.py @@ -0,0 +1,31 @@ +import os + +SECRET_KEY = os.environ.get("SUPERSET_SECRET_KEY", "change-in-production") + +SQLALCHEMY_DATABASE_URI = os.environ.get( + "SQLALCHEMY_DATABASE_URI", + "postgresql://arcadia:arcadia123@db:5432/superset" +) + +ENABLE_CORS = True +CORS_OPTIONS = { + "supports_credentials": True, + "allow_headers": ["*"], + "resources": {r"/api/*": {"origins": "*"}}, +} + +FEATURE_FLAGS = { + "EMBEDDED_SUPERSET": True, + "ENABLE_TEMPLATE_PROCESSING": True, + "ALERT_REPORTS": True, + "DRILL_TO_DETAIL": True, +} + +SUPERSET_WEBSERVER_TIMEOUT = 300 + +CACHE_CONFIG = { + "CACHE_TYPE": "SimpleCache", + "CACHE_DEFAULT_TIMEOUT": 300, +} + +APP_NAME = "Arcadia Insights"