-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (136 loc) · 5.2 KB
/
Makefile
File metadata and controls
159 lines (136 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Superset upstream configuration
SUPERSET_REPO = https://github.com/apache/incubator-superset.git
SUPERSET_VERSION = 0.34.1
SUPERSET_REMOTE = superset
# Directory to sync superset upstream with
SUPERSET_DIR = superset
# Directory with custom code to copy into SUPERSET_DIR
PATCH_SOURCE_DIR = srcd
# Directory with template for docker-compose.override.yml
OVERRIDE_TEMPLATE_PATH := $(PATCH_SOURCE_DIR)/contrib/docker/docker-compose.override.yml
# Directory for the sourced global docker-compose.override.yml
OVERRIDE_OUTPUT_PATH := $(HOME)/.sourced/compose-files/__active__/docker-compose.override.yml
# Directory for the docker-compose.override.yml backup
OVERRIDE_BACKUP_PATH := $(OVERRIDE_OUTPUT_PATH).bak
# Name of the docker image to build
DOCKER_IMAGE_NAME ?= srcd/sourced-ui
# Docker registry where the docker image should be pushed to.
DOCKER_REGISTRY ?= docker.io
# Docker organization to be used at the docker image name.
DOCKER_ORG ?= srcd
# Username used to login on the docker registry.
DOCKER_USERNAME ?=
# Password used to login on the docker registry.
DOCKER_PASSWORD ?=
# When `make docker-push`, setting DOCKER_PUSH_LATEST to any non-empty value
# will cause make docker-push to also push the latest tag.
DOCKER_PUSH_LATEST ?=
# Tools
STAT := stat -c
ifeq ($(shell uname),Darwin)
STAT := stat -f
endif
SOURCED_UI_ABS_PATH := $(shell pwd)
# Get UID on host machine, it will be used inside a container 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)
LOCAL_USER := $(shell $(STAT) "%u" superset/superset)
export SOURCED_UI_ABS_PATH
export LOCAL_USER
# Build information
VERSION ?= latest
# Travis CI
ifneq ($(TRAVIS_TAG), )
VERSION := $(TRAVIS_TAG)
endif
# IS_RELEASE is "true" if tag is semantic version and not a pre-release
IS_RELEASE := $(shell echo $(VERSION) | grep -q -E '^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$$' && echo "true" || true)
all: build build-dev
# Clean, and copy src-d files in the superset repository
.PHONY: patch
patch: clean apply-patch
# Copy src-d files in the superset repository
.PHONY: apply-patch
apply-patch:
cp -r $(PATCH_SOURCE_DIR)/* $(SUPERSET_DIR)/
# Start a watcher that will run 'make apply-patch' automatically when 'srcd' changes
# It will require either inotify or fswatch. More info in CONTRIBUTING.md
.PHONY: watch
watch:
@DIRECTORY_TO_OBSERVE=$(PATCH_SOURCE_DIR) bash watcher
# Writes the proper `docker-compose.override.yml` as the sourced global override file
.PHONY: set-override
set-override: $(OVERRIDE_BACKUP_PATH)
@awk '{ system("echo \""$$0"\"") }' $(OVERRIDE_TEMPLATE_PATH) > $(OVERRIDE_OUTPUT_PATH)
# Creates a backup of the sourced global override file if it exists
$(OVERRIDE_BACKUP_PATH):
@mkdir -p ~/.sourced/compose-files/__active__
@if [ -f "$(OVERRIDE_OUTPUT_PATH)" ]; then \
cp $(OVERRIDE_OUTPUT_PATH) $(OVERRIDE_BACKUP_PATH); \
else \
echo "\033[33mno docker-compose.override.yml to backup\033[0m"; \
fi;
# Prepares the development enviroment with hot reloading
.PHONY: dev-prepare
dev-prepare: set-override watch
# Create docker image
.PHONY: patch
build: patch
docker build --pull -t $(DOCKER_IMAGE_NAME):$(VERSION) -f superset/contrib/docker/Dockerfile $(SUPERSET_DIR)
build-dev: patch
docker build --pull -t $(DOCKER_IMAGE_NAME):$(VERSION)-dev -f superset/contrib/docker/Dockerfile $(SUPERSET_DIR) --build-arg DEV_BUILD=true
.PHONY: docker-validate
docker-validate:
@if [ -z "$(DOCKER_USERNAME)" ]; then \
echo "DOCKER_USERNAME variable cannot be empty."; \
exit 1; \
fi; \
if [ -z "$(DOCKER_PASSWORD)" ]; then \
echo "DOCKER_PASSWORD variable cannot be empty."; \
exit 1; \
fi
.PHONY: docker-login
docker-login: docker-validate
@docker login -u "$(DOCKER_USERNAME)" -p "$(DOCKER_PASSWORD)" $(DOCKER_REGISTRY); \
# Push the docker image
.PHONY: docker-push
docker-push: docker-login build
@if [ "$(BRANCH)" == "master" && "$(DOCKER_PUSH_MASTER)" == "" ]; then \
echo "docker-push is disabled on master branch" \
exit 1; \
fi; \
docker push $(DOCKER_IMAGE_NAME):$(VERSION); \
if [ -n "$(DOCKER_PUSH_LATEST)" ]; then \
docker tag $(DOCKER_IMAGE_NAME):$(VERSION) \
$(DOCKER_IMAGE_NAME):latest; \
docker push $(DOCKER_IMAGE_NAME):latest; \
fi;
.PHONY: docker-push-latest-release
docker-push-latest-release:
@DOCKER_PUSH_LATEST=$(IS_RELEASE) make docker-push
# Clean superset directory from copied files
.PHONY: clean
clean:
rm -f "$(SUPERSET_DIR)/superset_config.py"
git clean -ffdx $(SUPERSET_DIR)
rm -f $(OVERRIDE_OUTPUT_PATH)
@if [ -f "$(OVERRIDE_BACKUP_PATH)" ]; then \
mv $(OVERRIDE_BACKUP_PATH) $(OVERRIDE_OUTPUT_PATH); \
else \
echo "\033[33mno docker-compose.override.yml.bak to restore\033[0m"; \
fi;
# Add superset upstream remote if doesn't exists
.PHONY: remote-add
remote-add:
@if ! git remote | grep -q superset; then \
git remote add -f $(SUPERSET_REMOTE) $(SUPERSET_REPO); \
fi; \
# Prints list of changed files in local superset and upstream
.PHONY: diff-stat
diff-stat: remote-add
git diff-tree --stat $(SUPERSET_VERSION) HEAD:$(SUPERSET_DIR)/
# Prints unified diff of local superset and upstream
.PHONY: diff
diff: remote-add
git diff-tree -p $(SUPERSET_VERSION) HEAD:$(SUPERSET_DIR)/