114 lines
3.3 KiB
YAML
114 lines
3.3 KiB
YAML
# =============================================================================
|
||
# Apache Superset - Docker Compose 配置
|
||
# MOMO Pro System - UAT 環境
|
||
# 用途:BI 分析平台,連接 UAT、GCP、DEV 環境資料庫
|
||
# =============================================================================
|
||
#
|
||
# 重要:Apache Superset 官方映像存在 theme.js 0 bytes bug
|
||
# 所有版本(1.5.3, 2.0.x, 2.1.x, 3.x, 4.x)都有這個問題
|
||
# 此配置包含啟動時自動修復腳本
|
||
# =============================================================================
|
||
|
||
services:
|
||
superset:
|
||
# 使用 2.1.3 版本 (3.x/4.x 的 theme.js 有 0 bytes bug)
|
||
image: apache/superset:2.1.3
|
||
container_name: momo-superset
|
||
restart: unless-stopped
|
||
ports:
|
||
- "127.0.0.1:8088:8088"
|
||
environment:
|
||
# 基本設定
|
||
- SUPERSET_SECRET_KEY=wooo_superset_secret_key_2026_momo_pro
|
||
- SUPERSET_LOAD_EXAMPLES=no
|
||
- TZ=Asia/Taipei
|
||
|
||
# 資料庫連線 (Superset 內部 metadata)
|
||
- DATABASE_HOST=superset-db
|
||
- DATABASE_PORT=5432
|
||
- DATABASE_USER=superset
|
||
- DATABASE_PASSWORD=Wooo_Superset_DB_2026
|
||
- DATABASE_DB=superset
|
||
|
||
# Redis 快取
|
||
- REDIS_HOST=superset-redis
|
||
- REDIS_PORT=6379
|
||
|
||
volumes:
|
||
- superset_home:/app/superset_home
|
||
- ./superset_config.py:/app/pythonpath/superset_config.py:ro
|
||
# theme.js 修復文件
|
||
- ./custom-assets/theme.entry.js:/tmp/theme-fix.js:ro
|
||
depends_on:
|
||
superset-db:
|
||
condition: service_healthy
|
||
superset-redis:
|
||
condition: service_healthy
|
||
networks:
|
||
- superset-network
|
||
healthcheck:
|
||
test: ["CMD", "curl", "-f", "http://localhost:8088/health"]
|
||
interval: 30s
|
||
timeout: 10s
|
||
retries: 5
|
||
start_period: 120s
|
||
command: >
|
||
bash -c "
|
||
echo '等待資料庫初始化...' &&
|
||
sleep 10 &&
|
||
echo '修復 theme.js 0-byte bug...' &&
|
||
for f in /app/superset/static/assets/theme.*.entry.js; do
|
||
if [ -f \"$$f\" ] && [ ! -s \"$$f\" ]; then
|
||
cp /tmp/theme-fix.js \"$$f\" &&
|
||
echo \"已修復: $$f\"
|
||
fi
|
||
done &&
|
||
superset db upgrade &&
|
||
superset fab create-admin --username admin --firstname Admin --lastname User --email admin@wooo.work --password <SUPERSET_ADMIN_PASSWORD> || true &&
|
||
superset init &&
|
||
echo 'Superset 啟動中...' &&
|
||
gunicorn --bind 0.0.0.0:8088 --workers 4 --timeout 120 --access-logfile - 'superset.app:create_app()'
|
||
"
|
||
|
||
superset-db:
|
||
image: postgres:15-alpine
|
||
container_name: superset-postgres
|
||
restart: unless-stopped
|
||
environment:
|
||
- POSTGRES_USER=superset
|
||
- POSTGRES_PASSWORD=Wooo_Superset_DB_2026
|
||
- POSTGRES_DB=superset
|
||
- TZ=Asia/Taipei
|
||
volumes:
|
||
- superset_db:/var/lib/postgresql/data
|
||
networks:
|
||
- superset-network
|
||
healthcheck:
|
||
test: ["CMD-SHELL", "pg_isready -U superset"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
|
||
superset-redis:
|
||
image: redis:7-alpine
|
||
container_name: superset-redis
|
||
restart: unless-stopped
|
||
volumes:
|
||
- superset_redis:/data
|
||
networks:
|
||
- superset-network
|
||
healthcheck:
|
||
test: ["CMD", "redis-cli", "ping"]
|
||
interval: 10s
|
||
timeout: 5s
|
||
retries: 5
|
||
|
||
volumes:
|
||
superset_home:
|
||
superset_db:
|
||
superset_redis:
|
||
|
||
networks:
|
||
superset-network:
|
||
driver: bridge
|