forked from ansible/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
250 lines (199 loc) · 6.96 KB
/
Makefile
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
GALAXY_RELEASE_IMAGE ?= galaxy
GALAXY_RELEASE_TAG ?= latest
GALAXY_VENV=/usr/share/galaxy/venv
DOCKER_COMPOSE=docker-compose -p galaxy -f ./scripts/docker/dev/compose.yml
.PHONY: help
help:
@echo "Prints help"
# ---------------------------------------------------------
# Common targets
# ---------------------------------------------------------
.PHONY: runserver
runserver:
python manage.py runserver 0.0.0.0:8888
.PHONY: celery
celery:
python manage.py celery worker --beat -Q 'celery,import_tasks,login_tasks,admin_tasks,user_tasks,star_tasks'
.PHONY: ng_server
ng_server:
cd /galaxy/galaxyui; ng serve --disable-host-check --host '0.0.0.0' --port '8000' --poll '5000' --watch --live-reload --progress=false ----proxy-config proxy.conf.js
.PHONY: waitenv
waitenv:
@echo "Waiting for services to start..."
python ./manage.py waitenv
.PHONY: migrate
migrate:
@echo "Run migrations"
python ./manage.py migrate --noinput
.PHONY: collectstatic
collectstatic:
python manage.py collectstatic --noinput --clear
.PHONY: clean
clean:
rm -rfv dist build *.egg-info
rm -rfv rpm-build debian deb-build
rm -rfv galaxyui/dist
find . -type f -name "*.pyc" -delete
.PHONY: createsuperuser
@echo Create super user
python ./manage.py createsuperuser
# ---------------------------------------------------------
# Build targets
# ---------------------------------------------------------
.PHONY: build/yarn
build/yarn:
cd galaxyui; yarn install
.PHONY: build/static
build/static:
cd galaxyui; ng build --prod --source-map
.PHONY: build/dist
build/dist: build/static
python setup.py clean bdist_wheel
GALAXY_VERSION=$$(python setup.py --version) \
&& ln -sf galaxy-$$GALAXY_VERSION-py2-none-any.whl dist/galaxy.whl
.PHONY: build/docker-dev
build/docker-dev:
docker build --rm -t galaxy-dev -f scripts/docker/dev/Dockerfile .
.PHONY: build/release
build/release:
@echo "Building base container..."
@docker build -t galaxy-base:latest \
-f scripts/docker/release/Dockerfile.base .
@echo "Building build container..."
@docker build -t galaxy-build:latest \
-f scripts/docker/release/Dockerfile.build .
@echo "Building galaxy container..."
@docker build -t $(GALAXY_RELEASE_IMAGE):$(GALAXY_RELEASE_TAG) \
-f scripts/docker/release/Dockerfile .
@echo "Building static container..."
@docker build -t $(GALAXY_RELEASE_IMAGE)-static:$(GALAXY_RELEASE_TAG) \
-f scripts/docker/release/Dockerfile.static .
# ---------------------------------------------------------
# Test targets
# ---------------------------------------------------------
.PHONY: test/flake8
test/flake8:
flake8 galaxy
.PHONY: test/jslint
test/jslint:
cd galaxyui; ng lint
# for some reason yarn won't add prettier to /usr/local/bin
.PHONY: test/prettier
test/prettier:
@echo "Checking formatting..."
@echo "If this fails, run make dev/prettier locally to format your code"
cd galaxyui; ./node_modules/.bin/prettier -l "src/**/*.less" "src/**/*.ts"
# ---------------------------------------------------------
# Docker targets
# ---------------------------------------------------------
.PHONY: docker/test-flake8
docker/test-flake8:
docker run --rm -i -t -v $(CURDIR):/galaxy galaxy-dev:latest make test/flake8
# ---------------------------------------------------------
# Development targets
# ---------------------------------------------------------
.PHONY: dev/build
dev/build: build/docker-dev
.PHONY: dev/createsuperuser
dev/createsuperuser:
@echo "Create Superuser"
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/python ./manage.py createsuperuser
.PHONY: dev/migrate
dev/migrate:
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/python ./manage.py migrate --noinput
.PHONY: dev/makemigrations
dev/makemigrations:
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/python ./manage.py makemigrations
.PHONY: dev/checkmigrations
dev/checkmigrations:
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/python ./manage.py makemigrations --dry-run --check
.PHONY: dev/compile-reqs
dev/compile-reqs:
pip-compile -o requirements/requirements.txt requirements/requirements.in
pip-compile -o requirements/dev-requirements.txt requirements/dev-requirements.in
.PHONY: dev/log
dev/log:
@$(DOCKER_COMPOSE) logs --tail 100 galaxy
.PHONY: dev/logf
dev/logf:
@$(DOCKER_COMPOSE) logs -f galaxy
.PHONY: dev/flake8
dev/flake8:
@echo "Running flake8"
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/flake8 galaxy
.PHONY: dev/jslint
dev/jslint:
@echo "Linting Javascript..."
@$(DOCKER_COMPOSE) exec galaxy bash -c 'cd galaxyui; ng lint'
# for some reason yarn won't add prettier to /usr/local/bin
.PHONY: dev/prettier
dev/prettier:
@echo "Running prettier..."
@$(DOCKER_COMPOSE) exec galaxy bash -c 'cd galaxyui; ./node_modules/.bin/prettier --write "src/**/*.less" "src/**/*.ts" "src/**/*.tsx"'
.PHONY: dev/shellcheck
dev/shellcheck:
@$(DOCKER_COMPOSE) exec galaxy bash -c '\
find ./scripts -name *.sh | xargs shellcheck'
.PHONY: dev/test
dev/test:
@echo "Running tests"
# TODO: Revert to $(GALAXY_VENV)/bin/python. Some tests (flake8 and yamllint) require
# tools on $PATH, this cannot be chieved with just $(GALAXY_VENV)/bin/python command.
# So virtual environment must be activated in order to expose these utilities.
# TODO: Since app is isolated in container already, it's probably acceptable to
# get rid of virtual environment and install python packages in system dirs.
# Other option are:
# - install side packages globally or
# - call tools using python api instead of shell commands.
@$(DOCKER_COMPOSE) exec galaxy bash -c '\
source $(GALAXY_VENV)/bin/activate; pytest galaxy'
.PHONY: dev/waitenv
dev/waitenv:
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/python ./manage.py waitenv
.PHONY: dev/pip_install
dev/pip_install:
@$(DOCKER_COMPOSE) exec galaxy $(GALAXY_VENV)/bin/pip install -r requirements.txt
# Start all containers detached
.PHONY: dev/up
dev/up:
$(DOCKER_COMPOSE) up
.PHONY: dev/up_detached
dev/up_detached:
$(DOCKER_COMPOSE) up -d
.PHONY: dev/attach
dev/attach:
# Run before dev/tmux to start containers detached and no processes running in the galaxy container.
$(DOCKER_COMPOSE) exec galaxy tmux attach
.PHONY: dev/down
dev/down:
$(DOCKER_COMPOSE) down
.PHONY: dev/restart
dev/restart:
# Restart one or more services
$(DOCKER_COMPOSE) restart $(filter-out $@,$(MAKECMDGOALS))
.PHONY: dev/stop
dev/stop:
# Stop one or more services
$(DOCKER_COMPOSE) stop $(filter-out $@,$(MAKECMDGOALS))
.PHONY: dev/rm
dev/rm:
# Remove services
$(DOCKER_COMPOSE) stop
$(DOCKER_COMPOSE) rm -f
.PHONY: dev/export-test-data
export-test-data:
@echo Export data to test-data/role_data.dmp.gz
$(DOCKER_COMPOSE) /galaxy/test-data/export.sh
.PHONY: dev/import-test-data
import_test_data:
@echo Import data from test-data/role_data.dmp.gz
$(DOCKER_COMPOSE) /galaxy/test-data/import.sh
.PHONY: dev/refresh-role-counts
refresh-role-counts:
@echo Refresh role counts
$(DOCKER_COMPOSE) $(GALAXY_VENV)/bin/python ./manage.py refresh_role_counts
.PHONY: dev/setup-metrics
dev/setup-metrics:
cd scripts/metrics-setup-playbook; ansible-playbook setup.yml
%:
@: