forked from mozilla/kitsune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (105 loc) · 3.52 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
DC_CI = "bin/dc.sh"
DC = $(shell which docker-compose)
default: help
@echo ""
@echo "You need to specify a subcommand."
@exit 1
help:
@echo "build - build docker images for dev"
@echo "run - docker-compose up the entire system for dev"
@echo ""
@echo "pull - pull the latest production images from Docker Hub"
@echo "init - initialize the database and install Node and Bower packages"
@echo "djshell - start a Django Python shell (ipython)"
@echo "dbshell - start a MySQL shell"
@echo "shell - start a bash shell"
@echo "runshell - start a bash shell with ports bound so you can run the server"
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "rebuild - force a rebuild of all of the docker images"
@echo "lint - check style with flake8, jshint, and stylelint"
@echo "test - run tests against local files"
@echo "test-image - run tests against files in docker image"
@echo "docs - generate Sphinx HTML documentation"
@echo "build-ci - build docker images for use in our CI pipeline"
@echo "test-ci - run tests against files in docker image built by CI"
.env:
@if [ ! -f .env ]; then \
echo "Copying .env-dist to .env..."; \
cp .env-dist .env; \
fi
.docker-build:
${MAKE} build
.docker-build-pull:
${MAKE} pull
.docker-build-full:
${MAKE} build-full
build: .docker-build-pull
${DC} build base-dev
touch .docker-build
build-full: .docker-build-pull
${DC} build full
# tag other images
${DC} build base base-dev staticfiles locales full-no-locales
touch .docker-build-full
pull: .env
-GIT_COMMIT_SHORT= ${DC} pull base base-dev staticfiles locales full-no-locales full mariadb elasticsearch redis
touch .docker-build-pull
rebuild: clean build
run: .docker-build-pull
${DC} up web
init: .docker-build-pull
${DC} run web bin/run-bootstrap.sh
shell: .docker-build-pull
${DC} run web bash
runshell: .docker-build-pull
${DC} run --service-ports web bash
djshell: .docker-build-pull
${DC} run web python manage.py shell
dbshell: .docker-build-pull
${DC} run web python manage.py dbshell
clean:
# python related things
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
# test related things
-rm -f .coverage
# docs files
-rm -rf docs/_build/
# state files
-rm -f .docker-build*
# node stuff
-rm -rf node_modules bower_components
lint: .docker-build-pull
${DC} run test flake8 kitsune
test: .docker-build-pull
${DC} run test
test-js: .docker-build-pull
${DC} run test-js
test-image: .docker-build-full
${DC} run test-image
lint-image: .docker-build-full
${DC} run test-image flake8 kitsune
lint-l10n: .env
@GIT_COMMIT_SHORT= ${DC} pull base > /dev/null 2>&1
@GIT_COMMIT_SHORT= ${DC} run lint-l10n
docs: .docker-build-pull
${DC} run web $(MAKE) -C docs/ clean
${DC} run web $(MAKE) -C docs/ html
###############
# For use in CI
###############
.docker-build-ci:
${MAKE} build-ci
build-ci: .docker-build-pull
${DC_CI} build full
# tag intermediate images using cache
${DC_CI} build base base-dev staticfiles locales full-no-locales
touch .docker-build-ci
test-ci: .docker-build-ci
${DC_CI} run test-image
test-js-ci: .docker-build-ci
${DC_CI} run test-image-js
lint-ci: .docker-build-ci
${DC_CI} run test-image flake8 kitsune
.PHONY: default clean build build-full pull docs init lint run djshell dbshell runshell shell test test-image lint-image lint-l10n rebuild build-ci test-ci test-js-ci lint-ci