forked from mozilla/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (61 loc) · 2.58 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
BASE_IMG_NAME = bedrock_base
DEV_IMG_NAME = bedrock_dev
GIT_SHA = $(shell git rev-parse HEAD)
FINAL_IMG_NAME = bedrock_dev_final:${GIT_SHA}
default:
@echo "You need to specify a subcommand."
@exit 1
help:
@echo "build - build docker containers for dev"
@echo "run - docker-compose up the entire system for dev"
@echo ""
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "test - run unit tests"
@echo "sync-all - sync external data to local database"
@echo "test-image - run tests on the code built into the docker image"
@echo "build-final - build final docker container for demo deployment"
@echo "docs - generate Sphinx HTML documentation, including API docs"
.docker-build:
${MAKE} build
.docker-build-final:
${MAKE} build-final
build:
docker build -f docker/dockerfiles/bedrock_base -t ${BASE_IMG_NAME} --pull .
docker build -f docker/dockerfiles/bedrock_dev -t ${DEV_IMG_NAME} .
-rm -f .docker-build-final
touch .docker-build
build-final: .docker-build
docker build -f docker/dockerfiles/bedrock_dev_final -t ${FINAL_IMG_NAME} .
touch .docker-build-final
run: .docker-build
docker run --env-file docker/envfiles/dev.env -p 8000:8000 -v "$$PWD:/app" ${DEV_IMG_NAME}
django-shell: .docker-build
docker run --user `id -u` -it --env-file docker/envfiles/dev.env -v "$$PWD:/app" ${DEV_IMG_NAME} python manage.py shell
shell: .docker-build
docker run --user `id -u` -it --env-file docker/envfiles/dev.env -v "$$PWD:/app" ${DEV_IMG_NAME} bash
sync-all: .docker-build
docker run --user `id -u` --env-file docker/envfiles/demo.env -v "$$PWD:/app" ${DEV_IMG_NAME} bin/sync-all.sh
clean:
# python related things
find . -name '*.egg-info' -exec rm -rf {} +
find . -name '*.egg' -exec rm -f {} +
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '__pycache__' -exec rm -rf {} +
# test related things
-rm -f .coverage
-rm -rf results
# static files
git clean -fdx static
# docs files
-rm -rf docs/_build/
# state files
-rm -f .docker-build
-rm -f .docker-build-final
test: .docker-build
docker run --user `id -u` --env-file docker/envfiles/test.env -v "$$PWD:/app" ${DEV_IMG_NAME} bin/run-tests.sh
test-image: .docker-build-final
docker run --env-file docker/envfiles/test.env ${FINAL_IMG_NAME} bin/run-tests.sh
docs:
docker run --user `id -u` --env-file docker/envfiles/dev.env -v "$$PWD:/app" ${DEV_IMG_NAME} bash -c "make -C docs/ clean && make -C docs/ html"
.PHONY: default clean build build-final docs run test sync-all test-image shell django-shell