Apache Superset has emerged as one of the most powerful and popular open-source business intelligence (BI) tools available today. Known for its modern UI, extensive visualization options, and compatibility with a wide range of SQL databases, it is an ideal choice for data engineers and analysts looking to democratize data access within their organizations. However, setting up Superset in a production environment can be daunting due to its complex architecture, which involves multiple components like the Flask application, Celery workers, and a metadata database.
In this guide, we will walk you through deploying Apache Superset using Docker Compose. This method is recommended for intermediate to advanced developers because it provides a reproducible, isolated, and scalable environment without cluttering your host system. By the end of this post, you will have a fully functional Superset instance running locally or on a remote server.
Prerequisites and Environment Setup
Before diving into the deployment process, ensure your development environment meets the following requirements:
- Docker & Docker Compose: Ensure both are installed and running. You can verify this by running
docker --versionanddocker-compose --version. - PostgreSQL: Superset requires a relational database for its metadata. While Docker Compose can spin up a Postgres container, in production, you should use a managed service or a standalone database instance.
- Redis: This is used for caching and as a result backend for Celery tasks.
- Flask App: The core Superset application.
For the purpose of this tutorial, we will use a monolithic Docker Compose configuration that includes all necessary services. This is perfect for development and staging environments.
Creating the Docker Compose Configuration
Create a new directory for your project and initialize a docker-compose.yml file. This file defines the services, networks, and volumes required for Superset to function correctly.
version: '3.8'
services:
redis:
image: redis:latest
ports:
- "6379:6379"
networks:
- superset_network
postgres:
image: postgres:13
environment:
POSTGRES_USER: superset
POSTGRES_PASSWORD: superset_pass
POSTGRES_DB: superset
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
networks:
- superset_network
superset:
image: apache/superset:latest
restart: always
ports:
- "8088:8088"
command: ["/app/docker/docker-entrypoint.sh"]
environment:
SUPERSET_SECRET_KEY: 'super-secret-key-for-production'
DATABASE_HOST: postgres
DATABASE_PORT: 5432
DATABASE_USER: superset
DATABASE_PASSWORD: superset_pass
DATABASE_DB: superset
volumes:
- superset_data:/app/superset_home
depends_on:
- redis
- postgres
networks:
- superset_network
volumes:
postgres_data:
superset_data:
networks:
superset_network:
driver: bridge
Initialization and User Creation
Once your docker-compose.yml is ready, start the services using the following command:
docker-compose up -d
After the containers are up and running, you need to initialize the database and create an admin user. Execute the following commands in your terminal:
# Initialize the database schema
docker-compose exec superset superset db upgrade
# Create an admin user
docker-compose exec superset superset fab create-admin \
--username admin \
--firstname Admin \
--lastname User \
--email admin@example.com \
--password admin
The superset fab create-admin command is crucial for securing your initial deployment. The superset db upgrade command ensures that the database schema is up to date with the version of Superset you are running.
Production Considerations
While the above setup is excellent for development, production deployments require additional hardening:
- Security: Never use default secret keys. Generate a strong, random key for
SUPERSET_SECRET_KEY. - Reverse Proxy: Place Nginx or Traefik in front of Superset to handle SSL termination and load balancing.
- Database Separation: Move the Postgres and Redis containers to external, managed services to ensure high availability and data persistence.
- Scaling: Use horizontal pod scaling (Kubernetes) or Docker Swarm to scale the
supersetandcelery-workerservices independently based on load.
Conclusion
Deploying Apache Superset via Docker Compose is a streamlined process that allows developers to get up and running quickly. By leveraging containerization, you ensure consistency across development, staging, and production environments. As your data needs grow, remember to refactor your architecture to include separate database instances, robust caching strategies, and secure reverse proxies. With Superset deployed, your team is poised to unlock the full potential of your data through intuitive and powerful visualizations.