-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.inc
75 lines (63 loc) · 2.17 KB
/
Makefile.inc
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
# SSH Agent Socket
ifeq (${OS},Windows_NT) # WSL2 (Windows)
SSH_AGENT_SOCK := ${SSH_AUTH_SOCK}
else
UNAME_S := $(shell uname -s)
ifeq (${UNAME_S},Darwin) # macOS
SSH_AGENT_SOCK := /run/host-services/ssh-auth.sock
else # Linux
SSH_AGENT_SOCK := ${SSH_AUTH_SOCK}
endif
endif
# Builds the Docker image and outputs the hash of the built image
DOCKER_BUILD_CMD := docker build --quiet \
--build-arg DOCS=${DOCS} \
--build-arg PORT=${PORT} \
--build-arg TOOLS=${TOOLS} \
--build-arg REQUIREMENTS=${REQUIREMENTS} \
--file ${DOCKERFILE} \
${ROOT}/${DOCS} | head -n 1
# Runs Docker with the specified image,
# mounting the Git root directory
# mounting the known_hosts (for GitHub authentication)
# mounting the SSH agent socket (for GitHub authentication)
DOCKER_BASE_CMD := docker run --rm -it -p ${PORT}:${PORT} \
-v ${ROOT}:/repo:ro \
-v ~/.ssh/known_hosts:/root/.ssh/known_hosts:ro \
-v ${SSH_AGENT_SOCK}:/ssh-agent:ro --env SSH_AUTH_SOCK=/ssh-agent \
$(or $(shell ${DOCKER_BUILD_CMD}), $(error "Command failed: ${DOCKER_BUILD_CMD}"))
# Serve the docs at <http://localhost:8000/> (default)
serve: ${DOCKERFILE}
${DOCKER_BASE_CMD} serve --dev-addr=0.0.0.0:${PORT}
# Builds the docs
build: ${DOCKERFILE}
${DOCKER_BASE_CMD} build
# Deploys the docs
gh-deploy: ${DOCKERFILE}
${DOCKER_BASE_CMD} gh-deploy --force
# Print version
version: ${DOCKERFILE}
${DOCKER_BASE_CMD} --version
# Print help
help: ${DOCKERFILE}
${DOCKER_BASE_CMD} --help
# Builds the image and prints its hash
build-image: ${DOCKERFILE}
echo $(shell ${DOCKER_BUILD_CMD})
# Download and update the BIB file
bib: clean-bib ${BIB_FILE}
${BIB_FILE}: download-bib fix-bib
# Download the BIB file
download-bib:
curl "https://researchr.org/downloadbibtex/bibliography/${RESEARCHR}" -o ${BIB_FILE}
# Fix the BIB file
fix-bib:
sed -i '' '1 s/^/% /' ${BIB_FILE}
sed -i '' 's/doi = {http.*\/\(10\..*\)}/doi = {\1}/' ${BIB_FILE}
sed -i '' '/doi = {http.*}/d' ${BIB_FILE}
sed -i '' 's/\ü/ü/' ${BIB_FILE}
# Remove the BIB file
clean-bib:
rm -f ${BIB_FILE}
.PHONY: serve new build deploy help build-image bib download-bib fix-bib clean-bib
.SILENT: