Apache Superset Feature Flags and Custom Themes in Docker| Sabbirz | Blog

Apache Superset Configuration Feature Flags, Custom Themes in Docker Setup 🛠️

Configure the Feature Flag of Apache Superset in Docker Installation

Apache Superset Feature Flags and Custom Themes in Docker

Data Analytics wsl tutorial Tech Stack Development open-source BI tools FEATURE_FLAGS Configuration Themes Python Business Intelligence Theming docker BI WSL2 Apache Superset Embedded Superset superset Custom Configuration FLUSHALL Feature Flags data visualization docker compose Redis caching Open Source

Before diving into advanced configuration, ensure you have Apache Superset installed using Docker and WSL (Windows Subsystem for Linux).

🚀 If you haven't, you can refer to our previous tutorial on Installing Apache Superset with Docker and WSL

Here is the video tutorial of HOW TO INSTALL APACHE SUPERSET WITH DOCKER AND WSL

🚀 Step 1: Initialize and Check Your Superset Environment

Whenever you make significant configuration changes, it's best practice to restart your Superset containers cleanly.

First, shut down any running containers:

docker compose down

Next, bring them back up. This command will rebuild and restart the services based on your current docker-compose.yml file:

docker compose up

⚙️ Step 2: Creating the Custom Configuration File

To apply customizations in a Dockerized Superset environment, we need to create a dedicated configuration file.

Create the file named superset_config_docker.py inside the docker/pythonpath_dev directory:

docker/pythonpath_dev/superset_config_docker.py

Why does this work without modifying docker-compose.yml?

Unlike many standard Docker setups where you must explicitly mount a new configuration file, the official Apache Superset Docker installation is specifically designed to automatically load and execute all Python files located within the docker/pythonpath_dev folder. This makes customization streamlined

🎨 Step 3: Basic Customization - Changing the Primary Color Theme

Let's start by adding a unique visual identity to your Superset instance by defining custom colors for both the default (light) and dark modes. This is achieved using the THEME_DEFAULT and THEME_DARK variables.

Add the following configuration block to your superset_config_docker.py:

# superset_config_docker.py

# --- 1. CUSTOM THEME CONFIGURATION ---
THEME_DEFAULT = {
    "token": {
        "colorPrimary": "#03c2fc", # Sets a vibrant custom blue as the primary color
        "colorSuccess": "#5ac189", # Custom green for success messages (Light Theme)
    }
}

THEME_DARK = {
    "algorithm": "dark",
    "token": {
        "colorPrimary": "#03c2fc", # Ensures the same primary blue for the dark theme
    }
}

*� You must flush the cache for this flag to take effect immediately across all users.

# Flush Redis cache
docker compose exec redis redis-cli FLUSHALL

💡 Step 4: Enabling and Configuring Feature Flags

Next, we will begin defining the core FEATURE_FLAGS dictionary, adding them one by one to see their effects.

A. Controlling List Views (Card View vs. List View)

Superset set default view to card view

By default, recent Superset versions may use a visually rich "List View" for listing dashboards and charts. If you prefer the classic, data-dense "Card View" for better scannability, you can activate the card view.

Add the FEATURE_FLAGS dictionary to your file and include LISTVIEWS_DEFAULT_CARD_VIEW:

# superset_config_docker.py

# ... theme config here ...

# --- 2. FEATURE FLAGS ---
FEATURE_FLAGS = {
    "LISTVIEWS_DEFAULT_CARD_VIEW": True,
}

*� Action Required: Changes to list views modify the frontend rendering significantly. You must flush the cache for this flag to take effect immediately across all users.

# Flush Redis cache
docker compose exec redis redis-cli FLUSHALL

B. Enabling Embedded Superset (iFrame Integration)

Superset Docker Embed Feature Flag

If your goal is to integrate Superset dashboards into other web applications using an <iframe>, you must enable the EMBEDDED_SUPERSET flag. This flag enables the necessary security and context settings for embedding.

Update your FEATURE_FLAGS dictionary:

# superset_config_docker.py

# ... theme config here ...

# --- 2. FEATURE FLAGS ---
FEATURE_FLAGS = {
    "LISTVIEWS_DEFAULT_CARD_VIEW": True,
    "EMBEDDED_SUPERSET": True,
}

🚨 Action Required: Embedding settings are highly sensitive and require a cache refresh.

# Flush Redis cache
docker compose exec redis redis-cli FLUSHALL

C. Configuring Alert Reports

Superset Docker Alert and reports Feature Flag

The ALERT_REPORTS flag controls the scheduled reporting and alerting functionality, allowing users to send scheduled reports of charts or dashboards via email.

Let's assume we are disabling this feature for now (or setting it to True if you're ready to configure workers).

Update your FEATURE_FLAGS dictionary:

# superset_config_docker.py

# ... theme config here ...

# --- 2. FEATURE FLAGS ---
FEATURE_FLAGS = {
    "LISTVIEWS_DEFAULT_CARD_VIEW": False,
    "EMBEDDED_SUPERSET": True,
    "ALERT_REPORTS": True,
}

If you are disabling reporting (False), it's wise to flush the cache to ensure all background workers stop checking for outdated reporting configurations.

# Flush Redis cache
docker compose exec redis redis-cli FLUSHALL

💾 Step 5: The Complete and Optimized Configuration File

To ensure stability and proper functioning, especially for features like thumbnail generation, your configuration needs a few critical components:

  1. SECRET_KEY: Absolutely crucial for security. Always set a unique, strong key
  2. Hostname Resolution: Necessary for internal services (like the screenshot/thumbnail worker) to correctly access the Superset web interface within the Docker network.
  3. Caching: Defining a cache for features like thumbnails ensures performance.

Complete superset_config_docker.py Example

# superset_config_docker.py

# 1. --- SECURITY: Set a strong, unique secret key for session signing ---
# IMPORTANT: UNCOMMENT AND REPLACE WITH YOUR OWN KEY!
# SECRET_KEY = 'sdfee7892323jkds8932423786dfsjn23490' [[SUGGESTED_ACTION_GENERATE_UNIQUE_KEY]]

# 2. --- HOSTNAME RESOLUTION (CRITICAL FOR DOCKER THUMBNAILS) ---
WEBDRIVER_BASEURL = "http://superset:8088"
PUBLIC_FOR_USER_DOMAIN = "superset:8088"

# 3. --- FEATURE FLAGS ---
FEATURE_FLAGS = {
    "THUMBNAILS": True,
    "THUMBNAILS_SQLA_LISTENERS": False,
    "HORIZONTAL_FILTER_BAR": False,
    "ALERT_REPORTS": True,
    "DASHBOARD_CROSS_FILTERS": False,
    "EMBEDDED_SUPERSET": True,
    "DASHBOARD_NATIVE_FILTERS": True,
    "LISTVIEWS_DEFAULT_CARD_VIEW": True,
}

# 4. --- CUSTOM THEME CONFIGURATION ---
THEME_DEFAULT = {
    "token": {
        "colorPrimary": "#03c2fc",
        "colorSuccess": "#5ac189",
    }
}

THEME_DARK = {
    "algorithm": "dark",
    "token": {
        "colorPrimary": "#03c2fc",
    }
}

# TIME_ZONE = 'Asia/Kolkata' # Optional: Set a specific timezone
# SESSION_COOKIE_SAMESITE = 'Lax' # Optional: Important for iFrame security

# 5. --- CACHE & DEBUG SETTINGS ---
DEBUG = False # Always set to False for production/long-term use!
THUMBNAIL_CACHE_TIMEOUT = 86400  # 1 day (seconds)
THUMBNAIL_CACHE_CONFIG = {
    'CACHE_KEY_PREFIX': 'superset_thumbnail',
    'CACHE_TYPE': 'RedisCache',
    'CACHE_REDIS_HOST': 'redis', # Uses the Redis service defined in docker-compose.yml
    'CACHE_REDIS_PORT': 6379,
    'CACHE_REDIS_DB': 1, # Use a different DB than the main Superset cache (usually DB 0)
}

wrap-up: Don't Forget to Restart and Clear Cache

After saving your superset_config_docker.py file, execute a full restart to load the new Python code:

docker compose down
docker compose up

And finally, ensure a pristine environment for all frontend changes by flushing the cache:

docker compose exec redis redis-cli FLUSHALL

By following these steps, you've successfully customized your Apache Superset instance, enabling key features like Embedding and applying your own Visual Themes—all within the robust Docker environment Happy visualizing 📊✨