diff --git a/Makefile b/Makefile index fbcddc3e..168fb400 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,21 @@ DOCKER_PASSWORD ?= # will cause make docker-push to also push the latest tag. DOCKER_PUSH_LATEST ?= +STAT := stat -c +LOGIN_USER := 0 # 'root' UID +ifeq ($(shell uname),Darwin) + STAT := stat -f + # In OSX there's no problem if the host user and the internal user are + # different when reading and accessing data trough docker volumes. + LOGIN_USER := superset +endif +SOURCED_UI_ABS_PATH := $(shell pwd) +LOCAL_USER := $(shell $(STAT) "%u" superset/superset) +export SOURCED_UI_ABS_PATH +export LOCAL_USER +export LOGIN_USER + + # Build information VERSION ?= latest # Travis CI @@ -55,14 +70,10 @@ apply-patch: watch: @DIRECTORY_TO_OBSERVE=$(PATCH_SOURCE_DIR) bash watcher -SOURCED_DIR_OWNER := `stat -c "%u" superset/superset` # Writes the proper `docker-compose.override.yml` as the sourced global override file .PHONY: set-override set-override: $(OVERRIDE_BACKUP_PATH) - @sed \ - -e "s~\$${SOURCED_UI_ABS_PATH}~`pwd`~" \ - -e "s~\$${LOCAL_USER:-}~$(SOURCED_DIR_OWNER)~" \ - $(OVERRIDE_TEMPLATE_PATH) > $(OVERRIDE_OUTPUT_PATH) + @awk '{ system("echo \""$$0"\"") }' $(OVERRIDE_TEMPLATE_PATH) > $(OVERRIDE_OUTPUT_PATH) # Writes the proper `docker-compose.override.yml` as the sourced global override file $(OVERRIDE_BACKUP_PATH): @@ -70,7 +81,7 @@ $(OVERRIDE_BACKUP_PATH): @if [ -f "$(OVERRIDE_OUTPUT_PATH)" ]; then \ cp $(OVERRIDE_OUTPUT_PATH) $(OVERRIDE_BACKUP_PATH); \ else \ - /bin/echo -e "\e[33mno docker-compose.override.yml to backup\e[0m"; \ + echo "\033[33mno docker-compose.override.yml to backup\033[0m"; \ fi; # Prepares the development enviroment with with hot reloading @@ -124,7 +135,7 @@ clean: @if [ -f "$(OVERRIDE_BACKUP_PATH)" ]; then \ mv $(OVERRIDE_BACKUP_PATH) $(OVERRIDE_OUTPUT_PATH); \ else \ - /bin/echo -e "\e[33mno docker-compose.override.yml.bak to restore\e[0m"; \ + echo "\033[33mno docker-compose.override.yml.bak to restore\033[0m"; \ fi; # Add superset upstream remote if doesn't exists diff --git a/srcd/contrib/docker/docker-compose.override.yml b/srcd/contrib/docker/docker-compose.override.yml index 01341e2a..15a2855c 100644 --- a/srcd/contrib/docker/docker-compose.override.yml +++ b/srcd/contrib/docker/docker-compose.override.yml @@ -1,11 +1,7 @@ version: '3.2' services: sourced-ui: - # Set the user as root inside of the container to have permissions to change - # internal `superset` UID and GUID, and make it match the host user. - # It will grant write access to the data from the volumes, - # inside of the container and on host file system (see #221) - user: 0:0 + user: ${LOGIN_USER:-superset}:${LOGIN_USER:-superset} volumes: - ${SOURCED_UI_ABS_PATH}/superset/superset:/home/superset/superset - ${SOURCED_UI_ABS_PATH}/superset/dashboards:/home/superset/dashboards diff --git a/watcher b/watcher index a09ba74e..036e7ccb 100755 --- a/watcher +++ b/watcher @@ -4,8 +4,8 @@ trap ctrl_c SIGINT function ctrl_c { make --no-print-directory clean && \ - echo -e "\e[92mPatch cleaned\e[0m" || \ - echo -e "\e[33mCould not clean patch\e[0m" + echo -e "\033[1;92mPatch cleaned\033[0m" || \ + echo -e "\033[1;33mCould not clean patch\033[0m" exit $? } @@ -29,11 +29,11 @@ elif command -v fswatch > /dev/null 2>&1; then wichWatcher=fswatch function watcher { watch_fswatch; } else - echo -e "\e[31m[ERROR] No watcher available\e[0m" + echo -e "\033[1;31m[ERROR] No watcher available\033[0m" echo "Neither 'inotify' nor 'fswatch' are available." echo "You can follow 'CONTRIBUTING.md' guidelines to install one of them," echo "" - echo -e "\e[33m[alternative]\e[0m follow these steps:" + echo -e "\033[1;33m[alternative]\033[0m follow these steps:" echo "1. run 'make set-override' first," echo "2. then 'make patch' every time you change a file in 'srcd' dir" echo "3. and 'make clean' once you finish developing" @@ -42,7 +42,7 @@ else fi make --no-print-directory apply-patch -echo -e "\e[92mWatching for changes in 'srcd'; using '${wichWatcher}' ...\e[0m" +echo -e "\033[1;92mWatching for changes in 'srcd'; using '${wichWatcher}' ...\033[0m" while watcher; do make --no-print-directory apply-patch done