diff --git a/apps/dokploy/public/templates/superset.svg b/apps/dokploy/public/templates/superset.svg new file mode 100644 index 00000000..522c3b28 --- /dev/null +++ b/apps/dokploy/public/templates/superset.svg @@ -0,0 +1,9 @@ + + + Superset + + + + + + diff --git a/apps/dokploy/templates/superset/docker-compose.yml b/apps/dokploy/templates/superset/docker-compose.yml new file mode 100644 index 00000000..1766b86b --- /dev/null +++ b/apps/dokploy/templates/superset/docker-compose.yml @@ -0,0 +1,62 @@ +# Note: this is an UNOFFICIAL production docker image build for Superset: +# - https://github.com/amancevice/docker-superset +# +# After deploying this image, you will need to run one of the two +# commands below in a terminal within the superset container: +# $ superset-demo # Initialise database + load demo charts/datasets +# $ superset-init # Initialise database only +# +# You will be prompted to enter the credentials for the admin user. + +services: + superset: + image: amancevice/superset + restart: always + depends_on: + - db + - redis + environment: + SECRET_KEY: ${SECRET_KEY} + MAPBOX_API_KEY: ${MAPBOX_API_KEY} + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + REDIS_PASSWORD: ${REDIS_PASSWORD} + volumes: + # Note: superset_config.py can be edited in Dokploy's UI Volume Mount + - ../files/superset/superset_config.py:/etc/superset/superset_config.py + + db: + image: postgres + restart: always + environment: + POSTGRES_USER: ${POSTGRES_USER} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + POSTGRES_DB: ${POSTGRES_DB} + volumes: + - postgres:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 30s + timeout: 10s + retries: 3 + networks: + - dokploy-network + + redis: + image: redis + restart: always + volumes: + - redis:/data + command: redis-server --requirepass ${REDIS_PASSWORD} + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] + interval: 30s + timeout: 10s + retries: 3 + networks: + - dokploy-network + +volumes: + postgres: + redis: diff --git a/apps/dokploy/templates/superset/index.ts b/apps/dokploy/templates/superset/index.ts new file mode 100644 index 00000000..6132f978 --- /dev/null +++ b/apps/dokploy/templates/superset/index.ts @@ -0,0 +1,67 @@ +import { + type DomainSchema, + type Schema, + type Template, + generatePassword, + generateRandomDomain, +} from "../utils"; + +export function generate(schema: Schema): Template { + const mapboxApiKey = ""; + const secretKey = generatePassword(30); + const postgresDb = "superset"; + const postgresUser = "superset"; + const postgresPassword = generatePassword(30); + const redisPassword = generatePassword(30); + + const domains: DomainSchema[] = [ + { + host: generateRandomDomain(schema), + port: 8088, + serviceName: "superset", + }, + ]; + + const envs = [ + `SECRET_KEY=${secretKey}`, + `MAPBOX_API_KEY=${mapboxApiKey}`, + `POSTGRES_DB=${postgresDb}`, + `POSTGRES_USER=${postgresUser}`, + `POSTGRES_PASSWORD=${postgresPassword}`, + `REDIS_PASSWORD=${redisPassword}`, + ]; + + const mounts: Template["mounts"] = [ + { + filePath: "./superset/superset_config.py", + content: ` +import os + +SECRET_KEY = os.getenv("SECRET_KEY") +MAPBOX_API_KEY = os.getenv("MAPBOX_API_KEY", "") + +CACHE_CONFIG = { + "CACHE_TYPE": "RedisCache", + "CACHE_DEFAULT_TIMEOUT": 300, + "CACHE_KEY_PREFIX": "superset_", + "CACHE_REDIS_HOST": "redis", + "CACHE_REDIS_PORT": 6379, + "CACHE_REDIS_DB": 1, + "CACHE_REDIS_URL": f"redis://:{os.getenv('REDIS_PASSWORD')}@redis:6379/1", +} + +FILTER_STATE_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_filter_"} +EXPLORE_FORM_DATA_CACHE_CONFIG = {**CACHE_CONFIG, "CACHE_KEY_PREFIX": "superset_explore_form_"} + +SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{os.getenv('POSTGRES_USER')}:{os.getenv('POSTGRES_PASSWORD')}@db:5432/{os.getenv('POSTGRES_DB')}" +SQLALCHEMY_TRACK_MODIFICATIONS = True + `.trim(), + }, + ]; + + return { + envs, + domains, + mounts, + }; +} diff --git a/apps/dokploy/templates/templates.ts b/apps/dokploy/templates/templates.ts index 9531eb7a..4cd167a5 100644 --- a/apps/dokploy/templates/templates.ts +++ b/apps/dokploy/templates/templates.ts @@ -1298,4 +1298,18 @@ export const templates: TemplateData[] = [ tags: ["developer", "tools"], load: () => import("./it-tools/index").then((m) => m.generate), }, + { + id: "superset", + name: "Superset (Unofficial)", + version: "latest", + description: "Data visualization and data exploration platform.", + logo: "superset.svg", + links: { + github: "https://github.com/amancevice/docker-superset", + website: "https://superset.apache.org", + docs: "https://superset.apache.org/docs/intro", + }, + tags: ["analytics", "bi", "dashboard", "database", "sql"], + load: () => import("./superset/index").then((m) => m.generate), + }, ];