feat: add initial
This commit is contained in:
commit
1b3f6693ac
6
.env
Normal file
6
.env
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
TAG=4.1.1
|
||||||
|
POSTGRES_USER=superset
|
||||||
|
POSTGRES_PASSWORD=f001f532a8aa7fd3238a1d661bce5180
|
||||||
|
POSTGRES_DB=postgres
|
||||||
|
METABASE_DB=superset
|
||||||
|
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
data/
|
201
docker-compose.yml
Normal file
201
docker-compose.yml
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
x-superset-image: &superset-image apachesuperset.docker.scarf.sh/apache/superset:${TAG:-latest-dev}
|
||||||
|
x-superset-build:
|
||||||
|
&superset-build
|
||||||
|
context: docker
|
||||||
|
x-superset-volumes:
|
||||||
|
&superset-volumes # /app/pythonpath_docker will be appended to the PYTHONPATH in the final container
|
||||||
|
- ./docker:/app/docker
|
||||||
|
- superset_home:/app/superset_home
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7
|
||||||
|
container_name: superset_cache
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- redis:/data
|
||||||
|
|
||||||
|
superset:
|
||||||
|
env_file:
|
||||||
|
- path: docker/.env # default
|
||||||
|
required: true
|
||||||
|
- path: docker/.env-local # optional override
|
||||||
|
required: false
|
||||||
|
build: *superset-build
|
||||||
|
command: ["run-server.sh"]
|
||||||
|
container_name: superset_app
|
||||||
|
user: "root"
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 8088:8088
|
||||||
|
depends_on:
|
||||||
|
superset-init:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
volumes: *superset-volumes
|
||||||
|
environment:
|
||||||
|
SUPERSET_LOG_LEVEL: "${SUPERSET_LOG_LEVEL:-info}"
|
||||||
|
|
||||||
|
superset-init:
|
||||||
|
build: *superset-build
|
||||||
|
command: ["init_superset.sh"]
|
||||||
|
container_name: superset_init
|
||||||
|
env_file:
|
||||||
|
- path: docker/.env # default
|
||||||
|
required: true
|
||||||
|
- path: docker/.env-local # optional override
|
||||||
|
required: false
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_started
|
||||||
|
redis:
|
||||||
|
condition: service_started
|
||||||
|
user: "root"
|
||||||
|
volumes: *superset-volumes
|
||||||
|
healthcheck:
|
||||||
|
disable: true
|
||||||
|
environment:
|
||||||
|
SUPERSET_LOAD_EXAMPLES: "${SUPERSET_LOAD_EXAMPLES:-no}"
|
||||||
|
SUPERSET_LOG_LEVEL: "${SUPERSET_LOG_LEVEL:-info}"
|
||||||
|
|
||||||
|
superset-worker:
|
||||||
|
build: *superset-build
|
||||||
|
container_name: superset_worker
|
||||||
|
command:
|
||||||
|
- celery
|
||||||
|
- --app=superset.tasks.celery_app:app
|
||||||
|
- worker
|
||||||
|
- -O
|
||||||
|
- fair
|
||||||
|
- -l
|
||||||
|
- INFO
|
||||||
|
- --concurrency=2
|
||||||
|
env_file:
|
||||||
|
- path: docker/.env # default
|
||||||
|
required: true
|
||||||
|
- path: docker/.env-local # optional override
|
||||||
|
required: false
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
superset-init:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
user: "root"
|
||||||
|
volumes: *superset-volumes
|
||||||
|
healthcheck:
|
||||||
|
test:
|
||||||
|
[
|
||||||
|
"CMD-SHELL",
|
||||||
|
"celery -A superset.tasks.celery_app:app inspect ping -d celery@$$HOSTNAME",
|
||||||
|
]
|
||||||
|
environment:
|
||||||
|
SUPERSET_LOG_LEVEL: "${SUPERSET_LOG_LEVEL:-info}"
|
||||||
|
|
||||||
|
superset-worker-beat:
|
||||||
|
build: *superset-build
|
||||||
|
container_name: superset_worker_beat
|
||||||
|
command:
|
||||||
|
- celery
|
||||||
|
- --app=superset.tasks.celery_app:app
|
||||||
|
- beat
|
||||||
|
- --pidfile
|
||||||
|
- /tmp/celerybeat.pid
|
||||||
|
- -l
|
||||||
|
- INFO
|
||||||
|
- -s
|
||||||
|
- /tmp/celerybeat-schedule
|
||||||
|
env_file:
|
||||||
|
- path: docker/.env # default
|
||||||
|
required: true
|
||||||
|
- path: docker/.env-local # optional override
|
||||||
|
required: false
|
||||||
|
restart: unless-stopped
|
||||||
|
depends_on:
|
||||||
|
superset-init:
|
||||||
|
condition: service_completed_successfully
|
||||||
|
user: "root"
|
||||||
|
volumes: *superset-volumes
|
||||||
|
healthcheck:
|
||||||
|
disable: true
|
||||||
|
environment:
|
||||||
|
SUPERSET_LOG_LEVEL: "${SUPERSET_LOG_LEVEL:-info}"
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
container_name: postgres
|
||||||
|
hostname: postgres
|
||||||
|
env_file:
|
||||||
|
- path: docker/.env # default
|
||||||
|
required: true
|
||||||
|
- path: docker/.env-local # optional override
|
||||||
|
required: false
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${POSTGRES_USER:-postgres}
|
||||||
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?database password required}
|
||||||
|
POSTGRES_DB: ${POSTGRES_DB:-app}
|
||||||
|
PGDATA: /var/lib/postgresql/data/pgdata
|
||||||
|
volumes:
|
||||||
|
- postgres_data:/var/lib/postgresql/data/pgdata # Persistent data storage
|
||||||
|
- ./init:/docker-entrypoint-initdb.d/ # Initialization scripts
|
||||||
|
- ./backup:/backup # Backup location
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 30s
|
||||||
|
shm_size: 256mb
|
||||||
|
command:
|
||||||
|
- "postgres"
|
||||||
|
- "-c"
|
||||||
|
- "max_connections=200"
|
||||||
|
- "-c"
|
||||||
|
- "shared_buffers=1GB"
|
||||||
|
- "-c"
|
||||||
|
- "effective_cache_size=3GB"
|
||||||
|
- "-c"
|
||||||
|
- "work_mem=16MB"
|
||||||
|
- "-c"
|
||||||
|
- "maintenance_work_mem=512MB"
|
||||||
|
- "-c"
|
||||||
|
- "random_page_cost=1.1"
|
||||||
|
- "-c"
|
||||||
|
- "temp_file_limit=10GB"
|
||||||
|
- "-c"
|
||||||
|
- "log_min_duration_statement=200ms"
|
||||||
|
- "-c"
|
||||||
|
- "idle_in_transaction_session_timeout=10s"
|
||||||
|
- "-c"
|
||||||
|
- "lock_timeout=1s"
|
||||||
|
- "-c"
|
||||||
|
- "statement_timeout=60s"
|
||||||
|
- "-c"
|
||||||
|
- "shared_preload_libraries=pg_stat_statements"
|
||||||
|
- "-c"
|
||||||
|
- "pg_stat_statements.max=10000"
|
||||||
|
- "-c"
|
||||||
|
- "pg_stat_statements.track=all"
|
||||||
|
|
||||||
|
pgbackups:
|
||||||
|
image: prodrigestivill/postgres-backup-local
|
||||||
|
container_name: postgres_backup
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./data/backup:/backups
|
||||||
|
environment:
|
||||||
|
- POSTGRES_HOST=postgres
|
||||||
|
- POSTGRES_DB=${POSTGRES_DB:-app}
|
||||||
|
- POSTGRES_USER=${POSTGRES_USER:-postgres}
|
||||||
|
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?database password required}
|
||||||
|
- SCHEDULE=@daily
|
||||||
|
- BACKUP_KEEP_DAYS=7
|
||||||
|
- BACKUP_KEEP_WEEKS=4
|
||||||
|
- BACKUP_KEEP_MONTHS=6
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres_data:
|
||||||
|
name: postgres_data
|
||||||
|
superset_home:
|
||||||
|
external: false
|
||||||
|
redis:
|
||||||
|
external: false
|
64
docker/.env
Normal file
64
docker/.env
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Allowing python to print() in docker
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
COMPOSE_PROJECT_NAME=superset
|
||||||
|
DEV_MODE=true
|
||||||
|
|
||||||
|
# database configurations (do not modify)
|
||||||
|
DATABASE_DB=superset
|
||||||
|
DATABASE_HOST=postgres
|
||||||
|
# Make sure you set this to a unique secure random value on production
|
||||||
|
DATABASE_PASSWORD=f001f532a8aa7fd3238a1d661bce5180
|
||||||
|
DATABASE_USER=superset
|
||||||
|
|
||||||
|
SUPERSET_LOAD_EXAMPLES=false
|
||||||
|
|
||||||
|
# database engine specific environment variables
|
||||||
|
# change the below if you prefer another database engine
|
||||||
|
DATABASE_PORT=5432
|
||||||
|
DATABASE_DIALECT=postgresql
|
||||||
|
POSTGRES_DB=superset
|
||||||
|
POSTGRES_USER=superset
|
||||||
|
# Make sure you set this to a unique secure random value on production
|
||||||
|
POSTGRES_PASSWORD=f001f532a8aa7fd3238a1d661bce5180
|
||||||
|
#MYSQL_DATABASE=superset
|
||||||
|
#MYSQL_USER=superset
|
||||||
|
#MYSQL_PASSWORD=superset
|
||||||
|
#MYSQL_RANDOM_ROOT_PASSWORD=yes
|
||||||
|
|
||||||
|
# Add the mapped in /app/pythonpath_docker which allows devs to override stuff
|
||||||
|
PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev
|
||||||
|
REDIS_HOST=redis
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
FLASK_DEBUG=true
|
||||||
|
SUPERSET_ENV=development
|
||||||
|
SUPERSET_LOAD_EXAMPLES=yes
|
||||||
|
CYPRESS_CONFIG=false
|
||||||
|
SUPERSET_PORT=8088
|
||||||
|
MAPBOX_API_KEY=''
|
||||||
|
|
||||||
|
# Make sure you set this to a unique secure random value on production
|
||||||
|
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
|
||||||
|
|
||||||
|
ENABLE_PLAYWRIGHT=false
|
||||||
|
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||||
|
BUILD_SUPERSET_FRONTEND_IN_DOCKER=true
|
||||||
|
SUPERSET_LOG_LEVEL=info
|
16
docker/Dockerfile
Normal file
16
docker/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM apache/superset:4.1.1
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN mkdir -p /app/pythonpath
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y libpq-dev gcc && \
|
||||||
|
pip install psycopg2 clickhouse-connect
|
||||||
|
|
||||||
|
|
||||||
|
# Copy the entrypoint script into the container
|
||||||
|
COPY superset_config.py /app/pythonpath/
|
||||||
|
COPY init_superset.sh /usr/bin/init_superset.sh
|
||||||
|
|
||||||
|
# Make sure the script is executable
|
||||||
|
RUN chmod +x /usr/bin/init_superset.sh
|
75
docker/README.md
Normal file
75
docker/README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
# Getting Started with Superset using Docker
|
||||||
|
|
||||||
|
Docker is an easy way to get started with Superset.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
1. [Docker](https://www.docker.com/get-started)
|
||||||
|
2. [Docker Compose](https://docs.docker.com/compose/install/)
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
The `/app/pythonpath` folder is mounted from [`./docker/pythonpath_dev`](./pythonpath_dev)
|
||||||
|
which contains a base configuration [`./docker/pythonpath_dev/superset_config.py`](./pythonpath_dev/superset_config.py)
|
||||||
|
intended for use with local development.
|
||||||
|
|
||||||
|
### Local overrides
|
||||||
|
|
||||||
|
In order to override configuration settings locally, simply make a copy of [`./docker/pythonpath_dev/superset_config_local.example`](./pythonpath_dev/superset_config_local.example)
|
||||||
|
into `./docker/pythonpath_dev/superset_config_docker.py` (git ignored) and fill in your overrides.
|
||||||
|
|
||||||
|
### Local packages
|
||||||
|
|
||||||
|
If you want to add Python packages in order to test things like databases locally, you can simply add a local requirements.txt (`./docker/requirements-local.txt`)
|
||||||
|
and rebuild your Docker stack.
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
|
||||||
|
1. Create `./docker/requirements-local.txt`
|
||||||
|
2. Add your new packages
|
||||||
|
3. Rebuild docker compose
|
||||||
|
1. `docker compose down -v`
|
||||||
|
2. `docker compose up`
|
||||||
|
|
||||||
|
## Initializing Database
|
||||||
|
|
||||||
|
The database will initialize itself upon startup via the init container ([`superset-init`](./docker-init.sh)). This may take a minute.
|
||||||
|
|
||||||
|
## Normal Operation
|
||||||
|
|
||||||
|
To run the container, simply run: `docker compose up`
|
||||||
|
|
||||||
|
After waiting several minutes for Superset initialization to finish, you can open a browser and view [`http://localhost:8088`](http://localhost:8088)
|
||||||
|
to start your journey.
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
While running, the container server will reload on modification of the Superset Python and JavaScript source code.
|
||||||
|
Don't forget to reload the page to take the new frontend into account though.
|
||||||
|
|
||||||
|
## Production
|
||||||
|
|
||||||
|
It is possible to run Superset in non-development mode by using [`docker-compose-non-dev.yml`](../docker-compose-non-dev.yml). This file excludes the volumes needed for development and uses [`./docker/.env-non-dev`](./.env-non-dev) which sets the variable `SUPERSET_ENV` to `production`.
|
||||||
|
|
||||||
|
## Resource Constraints
|
||||||
|
|
||||||
|
If you are attempting to build on macOS and it exits with 137 you need to increase your Docker resources. See instructions [here](https://docs.docker.com/docker-for-mac/#advanced) (search for memory)
|
51
docker/apt-install.sh
Executable file
51
docker/apt-install.sh
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Ensure this script is run as root
|
||||||
|
if [[ $EUID -ne 0 ]]; then
|
||||||
|
echo "This script must be run as root" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for required arguments
|
||||||
|
if [[ $# -lt 1 ]]; then
|
||||||
|
echo "Usage: $0 <package1> [<package2> ...]" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Colors for better logging (optional)
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
RED='\033[0;31m'
|
||||||
|
RESET='\033[0m'
|
||||||
|
|
||||||
|
# Install packages with clean-up
|
||||||
|
echo -e "${GREEN}Updating package lists...${RESET}"
|
||||||
|
apt-get update -qq
|
||||||
|
|
||||||
|
echo -e "${GREEN}Installing packages: $@${RESET}"
|
||||||
|
apt-get install -yqq --no-install-recommends "$@"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Autoremoving unnecessary packages...${RESET}"
|
||||||
|
apt-get autoremove -y
|
||||||
|
|
||||||
|
echo -e "${GREEN}Cleaning up package cache and metadata...${RESET}"
|
||||||
|
apt-get clean
|
||||||
|
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
echo -e "${GREEN}Installation and cleanup complete.${RESET}"
|
77
docker/docker-bootstrap.sh
Executable file
77
docker/docker-bootstrap.sh
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
set -eo pipefail
|
||||||
|
|
||||||
|
# Make python interactive
|
||||||
|
if [ "$DEV_MODE" == "true" ]; then
|
||||||
|
if command -v uv > /dev/null 2>&1; then
|
||||||
|
echo "Reinstalling the app in editable mode"
|
||||||
|
uv pip install -e .
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
REQUIREMENTS_LOCAL="/app/docker/requirements-local.txt"
|
||||||
|
# If Cypress run – overwrite the password for admin and export env variables
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
export SUPERSET_CONFIG=tests.integration_tests.superset_test_config
|
||||||
|
export SUPERSET_TESTENV=true
|
||||||
|
export SUPERSET__SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://superset:superset@db:5432/superset
|
||||||
|
fi
|
||||||
|
if [[ "$DATABASE_DIALECT" == postgres* ]] ; then
|
||||||
|
echo "Installing postgres requirements"
|
||||||
|
if command -v uv > /dev/null 2>&1; then
|
||||||
|
# Use uv in newer images
|
||||||
|
uv pip install -e .[postgres]
|
||||||
|
else
|
||||||
|
# Use pip in older images
|
||||||
|
pip install -e .[postgres]
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Make sure we have dev requirements installed
|
||||||
|
#
|
||||||
|
if [ -f "${REQUIREMENTS_LOCAL}" ]; then
|
||||||
|
echo "Installing local overrides at ${REQUIREMENTS_LOCAL}"
|
||||||
|
uv pip install --no-cache-dir -r "${REQUIREMENTS_LOCAL}"
|
||||||
|
else
|
||||||
|
echo "Skipping local overrides"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${1}" in
|
||||||
|
worker)
|
||||||
|
echo "Starting Celery worker..."
|
||||||
|
# setting up only 2 workers by default to contain memory usage in dev environments
|
||||||
|
celery --app=superset.tasks.celery_app:app worker -O fair -l INFO --concurrency=${CELERYD_CONCURRENCY:-2}
|
||||||
|
;;
|
||||||
|
beat)
|
||||||
|
echo "Starting Celery beat..."
|
||||||
|
rm -f /tmp/celerybeat.pid
|
||||||
|
celery --app=superset.tasks.celery_app:app beat --pidfile /tmp/celerybeat.pid -l INFO -s "${SUPERSET_HOME}"/celerybeat-schedule
|
||||||
|
;;
|
||||||
|
app)
|
||||||
|
echo "Starting web app (using development server)..."
|
||||||
|
flask run -p 8088 --with-threads --reload --debugger --host=0.0.0.0
|
||||||
|
;;
|
||||||
|
app-gunicorn)
|
||||||
|
echo "Starting web app..."
|
||||||
|
/usr/bin/run-server.sh
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown Operation!!!"
|
||||||
|
;;
|
||||||
|
esac
|
34
docker/docker-entrypoint-initdb.d/examples-init.sh
Executable file
34
docker/docker-entrypoint-initdb.d/examples-init.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
# Creates the examples database and respective user. This database location
|
||||||
|
# and access credentials are defined on the environment variables
|
||||||
|
# ------------------------------------------------------------------------
|
||||||
|
set -e
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" <<-EOSQL
|
||||||
|
CREATE USER ${EXAMPLES_USER} WITH PASSWORD '${EXAMPLES_PASSWORD}';
|
||||||
|
CREATE DATABASE ${EXAMPLES_DB};
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE ${EXAMPLES_DB} TO ${EXAMPLES_USER};
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "${POSTGRES_USER}" -d "${EXAMPLES_DB}" <<-EOSQL
|
||||||
|
GRANT ALL ON SCHEMA public TO ${EXAMPLES_USER};
|
||||||
|
EOSQL
|
44
docker/docker-frontend.sh
Executable file
44
docker/docker-frontend.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Packages needed for puppeteer:
|
||||||
|
if [ "$PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" = "false" ]; then
|
||||||
|
apt update
|
||||||
|
apt install -y chromium
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$BUILD_SUPERSET_FRONTEND_IN_DOCKER" = "true" ]; then
|
||||||
|
echo "Building Superset frontend in dev mode inside docker container"
|
||||||
|
cd /app/superset-frontend
|
||||||
|
|
||||||
|
if [ "$NPM_RUN_PRUNE" = "true" ]; then
|
||||||
|
echo "Running `npm run prune`"
|
||||||
|
npm run prune
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running `npm install`"
|
||||||
|
npm install
|
||||||
|
|
||||||
|
echo "Start webpack dev server"
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Skipping frontend build steps - YOU NEED TO RUN IT MANUALLY ON THE HOST!"
|
||||||
|
echo "https://superset.apache.org/docs/contributing/development/#webpack-dev-server"
|
||||||
|
fi
|
82
docker/docker-init.sh
Executable file
82
docker/docker-init.sh
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
set -e
|
||||||
|
|
||||||
|
#
|
||||||
|
# Always install local overrides first
|
||||||
|
#
|
||||||
|
/app/docker/docker-bootstrap.sh
|
||||||
|
|
||||||
|
if [ "$SUPERSET_LOAD_EXAMPLES" = "yes" ]; then
|
||||||
|
STEP_CNT=4
|
||||||
|
else
|
||||||
|
STEP_CNT=3
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo_step() {
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
|
Init Step ${1}/${STEP_CNT} [${2}] -- ${3}
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
ADMIN_PASSWORD="${ADMIN_PASSWORD:-admin}"
|
||||||
|
# If Cypress run – overwrite the password for admin and export env variables
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
ADMIN_PASSWORD="general"
|
||||||
|
export SUPERSET_CONFIG=tests.integration_tests.superset_test_config
|
||||||
|
export SUPERSET_TESTENV=true
|
||||||
|
export SUPERSET__SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://superset:superset@db:5432/superset
|
||||||
|
fi
|
||||||
|
# Initialize the database
|
||||||
|
echo_step "1" "Starting" "Applying DB migrations"
|
||||||
|
superset db upgrade
|
||||||
|
echo_step "1" "Complete" "Applying DB migrations"
|
||||||
|
|
||||||
|
# Create an admin user
|
||||||
|
echo_step "2" "Starting" "Setting up admin user ( admin / $ADMIN_PASSWORD )"
|
||||||
|
superset fab create-admin \
|
||||||
|
--username admin \
|
||||||
|
--firstname Superset \
|
||||||
|
--lastname Admin \
|
||||||
|
--email admin@superset.com \
|
||||||
|
--password "$ADMIN_PASSWORD"
|
||||||
|
echo_step "2" "Complete" "Setting up admin user"
|
||||||
|
# Create default roles and permissions
|
||||||
|
echo_step "3" "Starting" "Setting up roles and perms"
|
||||||
|
superset init
|
||||||
|
echo_step "3" "Complete" "Setting up roles and perms"
|
||||||
|
|
||||||
|
if [ "$SUPERSET_LOAD_EXAMPLES" = "yes" ]; then
|
||||||
|
# Load some data to play with
|
||||||
|
echo_step "4" "Starting" "Loading examples"
|
||||||
|
# If Cypress run which consumes superset_test_config – load required data for tests
|
||||||
|
if [ "$CYPRESS_CONFIG" == "true" ]; then
|
||||||
|
superset load_test_users
|
||||||
|
superset load_examples --load-test-data
|
||||||
|
else
|
||||||
|
superset load_examples
|
||||||
|
fi
|
||||||
|
echo_step "4" "Complete" "Loading examples"
|
||||||
|
fi
|
26
docker/entrypoints/docker-ci.sh
Executable file
26
docker/entrypoints/docker-ci.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
/app/docker/docker-init.sh
|
||||||
|
|
||||||
|
# TODO: copy config overrides from ENV vars
|
||||||
|
|
||||||
|
# TODO: run celery in detached state
|
||||||
|
export SERVER_THREADS_AMOUNT=8
|
||||||
|
# start up the web server
|
||||||
|
|
||||||
|
/usr/bin/run-server.sh
|
36
docker/entrypoints/run-server.sh
Normal file
36
docker/entrypoints/run-server.sh
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
HYPHEN_SYMBOL='-'
|
||||||
|
|
||||||
|
gunicorn \
|
||||||
|
--bind "${SUPERSET_BIND_ADDRESS:-0.0.0.0}:${SUPERSET_PORT:-8088}" \
|
||||||
|
--access-logfile "${ACCESS_LOG_FILE:-$HYPHEN_SYMBOL}" \
|
||||||
|
--error-logfile "${ERROR_LOG_FILE:-$HYPHEN_SYMBOL}" \
|
||||||
|
--workers ${SERVER_WORKER_AMOUNT:-1} \
|
||||||
|
--worker-class ${SERVER_WORKER_CLASS:-gthread} \
|
||||||
|
--threads ${SERVER_THREADS_AMOUNT:-20} \
|
||||||
|
--log-level "${GUNICORN_LOGLEVEL:info}" \
|
||||||
|
--timeout ${GUNICORN_TIMEOUT:-60} \
|
||||||
|
--keep-alive ${GUNICORN_KEEPALIVE:-2} \
|
||||||
|
--max-requests ${WORKER_MAX_REQUESTS:-0} \
|
||||||
|
--max-requests-jitter ${WORKER_MAX_REQUESTS_JITTER:-0} \
|
||||||
|
--limit-request-line ${SERVER_LIMIT_REQUEST_LINE:-0} \
|
||||||
|
--limit-request-field_size ${SERVER_LIMIT_REQUEST_FIELD_SIZE:-0} \
|
||||||
|
"${FLASK_APP}"
|
49
docker/frontend-mem-nag.sh
Executable file
49
docker/frontend-mem-nag.sh
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# We need at least 3GB of free mem...
|
||||||
|
MIN_MEM_FREE_GB=3
|
||||||
|
MIN_MEM_FREE_KB=$(($MIN_MEM_FREE_GB*1000000))
|
||||||
|
|
||||||
|
echo_mem_warn() {
|
||||||
|
MEM_FREE_KB=$(awk '/MemFree/ { printf "%s \n", $2 }' /proc/meminfo)
|
||||||
|
MEM_FREE_GB=$(awk '/MemFree/ { printf "%s \n", $2/1024/1024 }' /proc/meminfo)
|
||||||
|
|
||||||
|
if [[ "${MEM_FREE_KB}" -lt "${MIN_MEM_FREE_KB}" ]]; then
|
||||||
|
cat <<EOF
|
||||||
|
===============================================
|
||||||
|
======== Memory Insufficient Warning =========
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
It looks like you only have ${MEM_FREE_GB}GB of
|
||||||
|
memory free. Please increase your Docker
|
||||||
|
resources to at least ${MIN_MEM_FREE_GB}GB
|
||||||
|
|
||||||
|
===============================================
|
||||||
|
======== Memory Insufficient Warning =========
|
||||||
|
===============================================
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "Memory check Ok [${MEM_FREE_GB}GB free]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Always nag if they're low on mem...
|
||||||
|
echo_mem_warn
|
18
docker/init_superset.sh
Normal file
18
docker/init_superset.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
echo "Performing initial setup..."
|
||||||
|
|
||||||
|
# Run database migration and create admin user
|
||||||
|
superset db upgrade
|
||||||
|
|
||||||
|
superset fab create-admin \
|
||||||
|
--username "${SUPERSET_ADMIN_USERNAME:-admin}" \
|
||||||
|
--firstname "${SUPERSET_ADMIN_FIRSTNAME:-Admin}" \
|
||||||
|
--lastname "${SUPERSET_ADMIN_LASTNAME:-User}" \
|
||||||
|
--email "${SUPERSET_ADMIN_EMAIL:-admin@example.com}" \
|
||||||
|
--password "${SUPERSET_ADMIN_PASSWORD:-admin}" \
|
||||||
|
|| echo "Admin user already exists, skipping creation."
|
||||||
|
|
||||||
|
# Initialize Superset
|
||||||
|
superset init
|
||||||
|
|
||||||
|
echo "Setup already done, skipping initialization steps."
|
127
docker/nginx/nginx.conf
Normal file
127
docker/nginx/nginx.conf
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
user nginx;
|
||||||
|
worker_processes 1;
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
include /etc/nginx/mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
|
'$status $body_bytes_sent [$connection_requests] "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
|
||||||
|
access_log /var/log/nginx/access.log main;
|
||||||
|
|
||||||
|
sendfile on;
|
||||||
|
#tcp_nopush on;
|
||||||
|
|
||||||
|
keepalive_timeout 30;
|
||||||
|
keepalive_requests 2;
|
||||||
|
|
||||||
|
###### Compression Stuff
|
||||||
|
|
||||||
|
# Enable Gzip compressed.
|
||||||
|
gzip on;
|
||||||
|
|
||||||
|
# Compression level (1-9).
|
||||||
|
# 5 is a perfect compromise between size and cpu usage, offering about
|
||||||
|
# 75% reduction for most ascii files (almost identical to level 9).
|
||||||
|
gzip_comp_level 5;
|
||||||
|
|
||||||
|
# Don't compress anything that's already small and unlikely to shrink much
|
||||||
|
# if at all (the default is 20 bytes, which is bad as that usually leads to
|
||||||
|
# larger files after gzipping).
|
||||||
|
gzip_min_length 256;
|
||||||
|
|
||||||
|
# Compress data even for clients that are connecting to us via proxies,
|
||||||
|
# identified by the "Via" header (required for CloudFront).
|
||||||
|
gzip_proxied any;
|
||||||
|
|
||||||
|
# Tell proxies to cache both the gzipped and regular version of a resource
|
||||||
|
# whenever the client's Accept-Encoding capabilities header varies;
|
||||||
|
# Avoids the issue where a non-gzip capable client (which is extremely rare
|
||||||
|
# today) would display gibberish if their proxy gave them the gzipped version.
|
||||||
|
gzip_vary on;
|
||||||
|
|
||||||
|
# Compress all output labeled with one of the following MIME-types.
|
||||||
|
gzip_types
|
||||||
|
application/atom+xml
|
||||||
|
application/javascript
|
||||||
|
application/json
|
||||||
|
application/rss+xml
|
||||||
|
application/vnd.ms-fontobject
|
||||||
|
application/x-font-ttf
|
||||||
|
application/x-web-app-manifest+json
|
||||||
|
application/xhtml+xml
|
||||||
|
application/xml
|
||||||
|
font/opentype
|
||||||
|
image/svg+xml
|
||||||
|
image/x-icon
|
||||||
|
text/css
|
||||||
|
text/plain
|
||||||
|
text/x-component;
|
||||||
|
# text/html is always compressed by HttpGzipModule
|
||||||
|
|
||||||
|
output_buffers 20 10m;
|
||||||
|
|
||||||
|
client_max_body_size 10m;
|
||||||
|
|
||||||
|
upstream superset_app {
|
||||||
|
server host.docker.internal:8088;
|
||||||
|
keepalive 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream superset_websocket {
|
||||||
|
server host.docker.internal:8080;
|
||||||
|
keepalive 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
location /ws {
|
||||||
|
proxy_pass http://superset_websocket;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://superset_app;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-Host $host;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
port_in_redirect off;
|
||||||
|
proxy_connect_timeout 300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
64
docker/pip-install.sh
Executable file
64
docker/pip-install.sh
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Default flag
|
||||||
|
REQUIRES_BUILD_ESSENTIAL=false
|
||||||
|
USE_CACHE=true
|
||||||
|
|
||||||
|
# Filter arguments
|
||||||
|
ARGS=()
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--requires-build-essential)
|
||||||
|
REQUIRES_BUILD_ESSENTIAL=true
|
||||||
|
;;
|
||||||
|
--no-cache)
|
||||||
|
USE_CACHE=false
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ARGS+=("$arg")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Install build-essential if required
|
||||||
|
if $REQUIRES_BUILD_ESSENTIAL; then
|
||||||
|
echo "Installing build-essential for package builds..."
|
||||||
|
apt-get update -qq \
|
||||||
|
&& apt-get install -yqq --no-install-recommends build-essential
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Choose whether to use pip cache
|
||||||
|
if $USE_CACHE; then
|
||||||
|
echo "Using pip cache..."
|
||||||
|
uv pip install "${ARGS[@]}"
|
||||||
|
else
|
||||||
|
echo "Disabling pip cache..."
|
||||||
|
uv pip install --no-cache-dir "${ARGS[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove build-essential if it was installed
|
||||||
|
if $REQUIRES_BUILD_ESSENTIAL; then
|
||||||
|
echo "Removing build-essential to keep the image lean..."
|
||||||
|
apt-get autoremove -yqq --purge build-essential \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Python packages installed successfully."
|
23
docker/pythonpath_dev/.gitignore
vendored
Normal file
23
docker/pythonpath_dev/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Ignore everything
|
||||||
|
*
|
||||||
|
# DON'T ignore the .gitignore
|
||||||
|
!.gitignore
|
||||||
|
!superset_config.py
|
||||||
|
!superset_config_local.example
|
27
docker/pythonpath_dev/superset_config_local.example
Normal file
27
docker/pythonpath_dev/superset_config_local.example
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is an example "local" configuration file. In order to set/override config
|
||||||
|
# options that ONLY apply to your local environment, simply copy/rename this file
|
||||||
|
# to docker/pythonpath_dev/superset_config_docker.py
|
||||||
|
# It ends up being imported by docker/superset_config.py which is loaded by
|
||||||
|
# superset/config.py
|
||||||
|
#
|
||||||
|
|
||||||
|
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://pguser:pgpwd@some.host/superset"
|
||||||
|
SQLALCHEMY_ECHO = True
|
2
docker/requirements-local.txt
Normal file
2
docker/requirements-local.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
uv==0.5.18
|
||||||
|
clickhouse-connect==0.8.13
|
22
docker/superset-websocket/config.json
Normal file
22
docker/superset-websocket/config.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"port": 8080,
|
||||||
|
"logLevel": "info",
|
||||||
|
"logToFile": false,
|
||||||
|
"logFilename": "app.log",
|
||||||
|
"statsd": {
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 8125,
|
||||||
|
"globalTags": []
|
||||||
|
},
|
||||||
|
"redis": {
|
||||||
|
"port": 6379,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"password": "",
|
||||||
|
"db": 0,
|
||||||
|
"ssl": false
|
||||||
|
},
|
||||||
|
"redisStreamPrefix": "async-events-",
|
||||||
|
"jwtAlgorithms": ["HS256"],
|
||||||
|
"jwtSecret": "CHANGE-ME-IN-PRODUCTION-GOTTA-BE-LONG-AND-SECRET",
|
||||||
|
"jwtCookieName": "async-token"
|
||||||
|
}
|
113
docker/superset_config.py
Normal file
113
docker/superset_config.py
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing,
|
||||||
|
# software distributed under the License is distributed on an
|
||||||
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
# KIND, either express or implied. See the License for the
|
||||||
|
# specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
#
|
||||||
|
# This file is included in the final Docker image and SHOULD be overridden when
|
||||||
|
# deploying the image to prod. Settings configured here are intended for use in local
|
||||||
|
# development environments. Also note that superset_config_docker.py is imported
|
||||||
|
# as a final step as a means to override "defaults" configured here
|
||||||
|
#
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
|
from celery.schedules import crontab
|
||||||
|
from flask_caching.backends.filesystemcache import FileSystemCache
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
DATABASE_DIALECT = os.getenv("DATABASE_DIALECT")
|
||||||
|
DATABASE_USER = os.getenv("DATABASE_USER")
|
||||||
|
DATABASE_PASSWORD = os.getenv("DATABASE_PASSWORD")
|
||||||
|
DATABASE_HOST = os.getenv("DATABASE_HOST")
|
||||||
|
DATABASE_PORT = os.getenv("DATABASE_PORT")
|
||||||
|
DATABASE_DB = os.getenv("DATABASE_DB")
|
||||||
|
|
||||||
|
SUPERSET_LOAD_EXAMPLES=False
|
||||||
|
|
||||||
|
|
||||||
|
# The SQLAlchemy connection string.
|
||||||
|
SQLALCHEMY_DATABASE_URI = (
|
||||||
|
f"{DATABASE_DIALECT}://"
|
||||||
|
f"{DATABASE_USER}:{DATABASE_PASSWORD}@"
|
||||||
|
f"{DATABASE_HOST}:{DATABASE_PORT}/{DATABASE_DB}"
|
||||||
|
)
|
||||||
|
|
||||||
|
REDIS_HOST = os.getenv("REDIS_HOST", "redis")
|
||||||
|
REDIS_PORT = os.getenv("REDIS_PORT", "6379")
|
||||||
|
REDIS_CELERY_DB = os.getenv("REDIS_CELERY_DB", "0")
|
||||||
|
REDIS_RESULTS_DB = os.getenv("REDIS_RESULTS_DB", "1")
|
||||||
|
|
||||||
|
RESULTS_BACKEND = FileSystemCache("/app/superset_home/sqllab")
|
||||||
|
|
||||||
|
CACHE_CONFIG = {
|
||||||
|
"CACHE_TYPE": "RedisCache",
|
||||||
|
"CACHE_DEFAULT_TIMEOUT": 300,
|
||||||
|
"CACHE_KEY_PREFIX": "superset_",
|
||||||
|
"CACHE_REDIS_HOST": REDIS_HOST,
|
||||||
|
"CACHE_REDIS_PORT": REDIS_PORT,
|
||||||
|
"CACHE_REDIS_DB": REDIS_RESULTS_DB,
|
||||||
|
}
|
||||||
|
DATA_CACHE_CONFIG = CACHE_CONFIG
|
||||||
|
|
||||||
|
|
||||||
|
class CeleryConfig:
|
||||||
|
broker_url = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_CELERY_DB}"
|
||||||
|
imports = (
|
||||||
|
"superset.sql_lab",
|
||||||
|
"superset.tasks.scheduler",
|
||||||
|
"superset.tasks.thumbnails",
|
||||||
|
"superset.tasks.cache",
|
||||||
|
)
|
||||||
|
result_backend = f"redis://{REDIS_HOST}:{REDIS_PORT}/{REDIS_RESULTS_DB}"
|
||||||
|
worker_prefetch_multiplier = 1
|
||||||
|
task_acks_late = False
|
||||||
|
beat_schedule = {
|
||||||
|
"reports.scheduler": {
|
||||||
|
"task": "reports.scheduler",
|
||||||
|
"schedule": crontab(minute="*", hour="*"),
|
||||||
|
},
|
||||||
|
"reports.prune_log": {
|
||||||
|
"task": "reports.prune_log",
|
||||||
|
"schedule": crontab(minute=10, hour=0),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CELERY_CONFIG = CeleryConfig
|
||||||
|
|
||||||
|
FEATURE_FLAGS = {"ALERT_REPORTS": True}
|
||||||
|
ALERT_REPORTS_NOTIFICATION_DRY_RUN = True
|
||||||
|
WEBDRIVER_BASEURL = "http://superset:8088/" # When using docker compose baseurl should be http://superset_app:8088/ # noqa: E501
|
||||||
|
# The base URL for the email report hyperlinks.
|
||||||
|
WEBDRIVER_BASEURL_USER_FRIENDLY = WEBDRIVER_BASEURL
|
||||||
|
SQLLAB_CTAS_NO_LIMIT = True
|
||||||
|
|
||||||
|
log_level_text = os.getenv("SUPERSET_LOG_LEVEL", "INFO")
|
||||||
|
LOG_LEVEL = getattr(logging, log_level_text.upper(), logging.INFO)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Optionally import superset_config_docker.py (which will have been included on
|
||||||
|
# the PYTHONPATH) in order to allow for local settings to be overridden
|
||||||
|
#
|
||||||
|
try:
|
||||||
|
import superset_config_docker
|
||||||
|
from superset_config_docker import * # noqa
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
f"Loaded your Docker configuration at " f"[{superset_config_docker.__file__}]"
|
||||||
|
)
|
||||||
|
except ImportError:
|
||||||
|
logger.info("Using default Docker config...")
|
3
init/01-create-metabase-db.sql
Normal file
3
init/01-create-metabase-db.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
CREATE DATABASE superset;
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE superset TO superset;
|
||||||
|
|
9
install-clickhouse-driver.sh
Executable file
9
install-clickhouse-driver.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export METABASE_VERSION=v0.51.1.2
|
||||||
|
export METABASE_CLICKHOUSE_DRIVER_VERSION=1.51.0
|
||||||
|
|
||||||
|
curl -L -o plugins/ch.jar https://github.com/ClickHouse/metabase-clickhouse-driver/releases/download/$METABASE_CLICKHOUSE_DRIVER_VERSION/clickhouse.metabase-driver.jar
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user