Skip to main content
Superset can automatically run setup and teardown scripts when creating and deleting workspaces. This is essential for:
  • Installing dependencies
  • Copying environment files
  • Creating database branches
  • Starting Docker containers
  • Cleaning up resources

Configuration File

Setup and teardown scripts are configured in .superset/config.json at the root of your repository:
.superset/config.json
Both setup and teardown accept arrays of commands. You can run multiple scripts or inline commands.

Setup Scripts

Setup scripts run when a new workspace is created. They prepare the workspace environment.

Basic Setup Script

.superset/setup.sh
Make your script executable: chmod +x .superset/setup.sh

Advanced Setup Script

Here’s a more comprehensive example from the Superset repository:
.superset/setup.sh (Advanced)
This script:
  1. Loads environment variables from the root repository
  2. Checks for required dependencies (bun, neonctl, jq, docker, caddy)
  3. Installs npm/bun dependencies
  4. Creates a Neon database branch for the workspace
  5. Starts an Electric SQL Docker container
  6. Allocates unique ports for all services
  7. Writes a workspace-specific .env file
  8. Sets up local MCP server configuration
  9. Seeds authentication tokens and local database

Teardown Scripts

Teardown scripts run when a workspace is deleted. They clean up resources.

Basic Teardown Script

.superset/teardown.sh

Advanced Teardown Script

From the Superset repository:
.superset/teardown.sh (Advanced)
This script:
  1. Stops and removes Electric SQL Docker container
  2. Deletes the Neon database branch
  3. Releases allocated ports
  4. Removes workspace-specific configuration files

Environment Variables

Superset provides these environment variables to setup/teardown scripts:

Using Environment Variables

Common Setup Tasks

Installing Dependencies

Copying Environment Files

Creating Database Branches

Starting Docker Containers

Allocating Unique Ports

Common Teardown Tasks

Stopping Docker Containers

Deleting Database Branches

Cleaning Up Files

Testing Scripts

Test your setup script before committing:
1

Create a Test Workspace

Use ⌘N to create a new workspace. Watch the setup script output in the terminal.
2

Verify Environment

Check that all dependencies installed correctly:
3

Test Application

Try running your application:
4

Test Teardown

Delete the workspace and verify cleanup worked:
  • Docker containers stopped
  • Database branches deleted
  • Files cleaned up

Error Handling

Make your scripts robust with proper error handling:

Best Practices

Make Scripts Idempotent

Scripts should work correctly when run multiple times. Check if resources already exist before creating them.

Use Exit Codes

Return 0 for success, non-zero for failure. Superset will show an error if setup fails.

Provide Clear Output

Use echo to show progress. Helps debug issues when scripts fail.

Clean Up on Failure

Use trap to clean up resources if setup fails halfway through.

Test Thoroughly

Test both setup and teardown scripts before deploying to your team.

Document Dependencies

Add comments listing required CLI tools (bun, docker, neonctl, etc.).

Troubleshooting

If the script fails without showing errors:
  1. Add set -e to exit on any error
  2. Add set -x to print commands as they execute
  3. Check the terminal output in Superset
  4. Test the script manually: ./.superset/setup.sh
If SUPERSET_WORKSPACE_NAME or SUPERSET_ROOT_PATH are empty:
  1. Make sure you’re running the script through Superset, not manually
  2. Check that the script is configured in .superset/config.json
  3. Verify the config file is in the repository root
If commands like bun or docker aren’t found:
  1. Make sure they’re installed on your system
  2. Check that they’re in your PATH
  3. Try running the command manually first
  4. Add the full path to the binary (e.g., /usr/local/bin/docker)
If Docker containers or database branches aren’t cleaned up:
  1. Add error suppression: command 2>/dev/null || true
  2. Check resource names match what setup created
  3. Manually clean up: docker ps -a, neonctl branches list
  4. Test teardown script manually before deleting workspace

Example: Full Setup Script

Here’s a complete, production-ready setup script:
.superset/setup.sh

Workspace Management

Learn how workspaces are created and deleted

Running Agents

Prepare environments for coding agents

Integrations

Connect to external services and tools