feat: Superset BI funcional — psycopg2, EMBEDDED_SUPERSET, gunicorn

This commit is contained in:
root 2026-03-17 12:05:39 -03:00
parent 64c413d131
commit 98b79be03d
4 changed files with 68 additions and 14 deletions

View File

@ -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:

View File

@ -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

23
docker/superset/init.sh Executable file
View File

@ -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()"

View File

@ -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"