diff --git a/docker-compose.yml b/docker-compose.yml index 0bdcdeb615e66..7d44b11999688 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,7 @@ x-superset-depends-on: &superset-depends-on - redis x-superset-volumes: &superset-volumes # /app/pythonpath_docker will be appended to the PYTHONPATH in the final container - - ./docker/docker-init.sh:/app/docker-init.sh - - ./docker/pythonpath_dev:/app/pythonpath + - ./docker:/app/docker - ./superset:/app/superset - ./superset-frontend:/app/superset-frontend - superset_home:/app/superset_home @@ -51,19 +50,21 @@ services: env_file: docker/.env image: *superset-image container_name: superset_app - command: ["flask", "run", "-p", "8088", "--with-threads", "--reload", "--debugger", "--host=0.0.0.0"] + command: ["/app/docker/docker-bootstrap.sh", "app"] restart: unless-stopped ports: - 8088:8088 + user: "root" depends_on: *superset-depends-on volumes: *superset-volumes superset-init: image: *superset-image container_name: superset_init - command: ["/app/docker-init.sh"] + command: ["/app/docker/docker-init.sh"] env_file: docker/.env depends_on: *superset-depends-on + user: "root" volumes: *superset-volumes superset-node: @@ -77,16 +78,17 @@ services: superset-worker: image: *superset-image container_name: superset_worker - command: ["celery", "worker", "--app=superset.tasks.celery_app:app", "-Ofair", "-l", "INFO"] + command: ["/app/docker/docker-bootstrap.sh", "worker"] env_file: docker/.env restart: unless-stopped depends_on: *superset-depends-on + user: "root" volumes: *superset-volumes superset-tests-worker: image: *superset-image container_name: superset_tests_worker - command: ["celery", "worker", "--app=superset.tasks.celery_app:app", "-Ofair", "-l", "INFO"] + command: ["/app/docker/docker-bootstrap.sh", "worker"] env_file: docker/.env environment: DATABASE_HOST: localhost @@ -96,6 +98,7 @@ services: REDIS_HOST: localhost network_mode: host depends_on: *superset-depends-on + user: "root" volumes: *superset-volumes volumes: diff --git a/docker/.env b/docker/.env index 643f2776f8f38..4857d44b38943 100644 --- a/docker/.env +++ b/docker/.env @@ -35,7 +35,7 @@ POSTGRES_PASSWORD=superset #MYSQL_RANDOM_ROOT_PASSWORD=yes # Add the mapped in /app/pythonpath_docker which allows devs to override stuff -PYTHONPATH=/app/pythonpath:/app/pythonpath_docker +PYTHONPATH=/app/pythonpath:/app/docker/pythonpath_dev REDIS_HOST=redis REDIS_PORT=6379 diff --git a/docker/docker-bootstrap.sh b/docker/docker-bootstrap.sh new file mode 100755 index 0000000000000..c60a6d21f75a9 --- /dev/null +++ b/docker/docker-bootstrap.sh @@ -0,0 +1,39 @@ +#!/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 + +REQUIREMENTS_LOCAL="/app/docker/requirements-local.txt" + +# +# Make sure we have dev requirements installed +# +if [ -f "${REQUIREMENTS_LOCAL}" ]; then + echo "Installing local overrides at ${REQUIREMENTS_LOCAL}" + pip install -r "${REQUIREMENTS_LOCAL}" +else + echo "Skipping local overrides" +fi + +if [[ "${1}" == "worker" ]]; then + echo "Starting Celery worker..." + celery worker --app=superset.tasks.celery_app:app -Ofair -l INFO +elif [[ "${1}" == "app" ]]; then + echo "Starting web app..." + flask run -p 8088 --with-threads --reload --debugger --host=0.0.0.0 +fi diff --git a/docker/docker-init.sh b/docker/docker-init.sh index a2e86b9836ffe..124e747f5f9ee 100755 --- a/docker/docker-init.sh +++ b/docker/docker-init.sh @@ -17,6 +17,11 @@ # set -e +# +# Always install local overrides first +# +/app/docker/docker-bootstrap.sh + STEP_CNT=4 echo_step() {