-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
109 lines (85 loc) · 3.24 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
SHELL:=/bin/bash
artifact-bucket:=s3://factually-settled-boxer-artifacts
artifact-prefix:=/docs-bundle/
ifeq ($(DRY_RUN),1)
DRY_RUN_FLAG = --dryrun
endif
ifeq ($(QUIET),1)
QUIET_FLAG = --quiet
endif
ifeq ($(SIZE_ONLY_SYNC),1)
SIZE_ONLY_FLAG = --size-only
endif
################################################
## run from machine with docker installed
## requires GNU Make
################################################
ubuntu:
docker compose run --rm ubuntu
open-local:
open http://localhost:5000
stop:
docker compose down --remove-orphans
serve: check-env check-region
docker compose run --entrypoint "/bin/bash" --service-ports local_development_server -c "make serve-mkdocs env=$(env) region=$(region)"
build: check-env check-region
docker compose run --entrypoint "/bin/bash" ubuntu -c "make build-mkdocs env=$(env) region=$(region)"
deploy: check-env check-region check-bucket-name
docker compose run --entrypoint "/bin/bash" ubuntu -c "make deploy-mkdocs env=$(env) region=$(region) bucket-name=$(bucket-name)"
#########################################################
## run from machine or container with required software
## awscli, python, pip, buildenv, GNU Make, etc.
#########################################################
setup-mkdocs: check-env check-region check-download-directory
curl https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/robots.txt/robots.txt --output $(download-directory)robots.txt
mv $(download-directory)robots.txt ./docs/robots.txt
build-mkdocs: check-env check-region clean install-requirements
eval "$$(buildenv -e $(env) -d $(region))" && \
mkdocs build
archive-mkdocs: check-env check-region check-version
tar \
--dereference --hard-dereference \
--directory ./site/ \
-cvf ./docs-site.tar \
. > ./manifest.txt
aws s3 cp $(DRY_RUN_FLAG) $(QUIET_FLAG) --no-progress --sse AES256 ./docs-site.tar $(artifact-bucket)$(artifact-prefix)$(version)/
aws s3 cp $(DRY_RUN_FLAG) $(QUIET_FLAG) --no-progress --sse AES256 ./manifest.txt $(artifact-bucket)$(artifact-prefix)$(version)/
get-mkdocs-archive: check-env check-region check-version clean check-download-directory
mkdir -p site
aws s3 cp $(DRY_RUN_FLAG) $(QUIET_FLAG) --no-progress $(artifact-bucket)$(artifact-prefix)$(version)/docs-site.tar $(download-directory)
tar \
--directory ./site/ \
-xf $(download-directory)docs-site.tar
deploy-mkdocs: check-env check-region check-bucket-name
aws s3 sync $(DRY_RUN_FLAG) $(QUIET_FLAG) $(SIZE_ONLY_FLAG) --no-progress --sse AES256 ./site/ s3://$(bucket-name)/
serve-mkdocs: check-env check-region clean install-requirements
eval "$$(buildenv -e $(env) -d $(region))" && \
mkdocs serve -v --dev-addr=0.0.0.0:5000
install-requirements:
pip install -r ./requirements.txt
clean: clean-site clean-archive-files
clean-site:
rm -rf ./site/
clean-archive-files:
rm -rf ./docs-site.tar
rm -rf ./manifest.txt
check-env:
ifndef env
$(error env is not defined)
endif
check-region:
ifndef region
$(error region is not defined)
endif
check-download-directory:
ifndef download-directory
$(error download-directory is not defined)
endif
check-version:
ifndef version
$(error version is not defined)
endif
check-bucket-name:
ifndef bucket-name
$(error bucket-name is not defined)
endif