-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (95 loc) · 2.41 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
.PHONY: docker-build docker-shell print-build-args \
default build \
print-docker-hub-image kill \
clean
#####
# user-facing variables
# override this with e.g.
# make BUILD_ENVIRONMENT=production build
# or
# make BUILD_ENVIRONMENT=gh-pages build
# as needed.
#
# recognized values are:
# - development
# - production
# - gh-pages
#
# The eleventy config file will set base URL as
# appropriate.
BUILD_ENVIRONMENT=development
#####
SHELL=bash
# docker bits
IMAGE_NAME=dsa-website
IMAGE_VERSION=0.1.0
print-image-name:
@echo $(IMAGE_NAME)
print-image-version:
@echo $(IMAGE_VERSION)
# eleventy
IMG=$(IMAGE_NAME):$(IMAGE_VERSION)
PACKAGE_DIR=/opt/site
ELEVENTY_JS_FILE=/src/.eleventy.js
IN_DIR = $$PWD/src
ASSETS_DIR = $$PWD/assets
OUT_DIR = $$PWD/out
# uncomment this to debug eleventy:
#DEBUG_FLAGS=DEBUG='*'
# change this to 'development' to use that environment
# for the build
ENVIRO_FLAGS=ELEVENTY_ENV=$(BUILD_ENVIRONMENT)
CTR_NAME=eleventy
DOCKER = docker -D
docker_args = \
-v $(IN_DIR):/src \
-v $(ASSETS_DIR):/assets \
-v $(OUT_DIR):/out \
$(MOUNT_PACKAGE) \
--name $(CTR_NAME) \
--workdir $(PACKAGE_DIR) \
--entrypoint sh
docker-build:
docker build -f Dockerfile -t $(IMG) .
# real kill target
kill_:
-$(DOCKER) stop -t 1 $(CTR_NAME) 2>/dev/null
-$(DOCKER) rm $(CTR_NAME) 2>/dev/null
# silent wrapper of kill_
kill:
make kill_ 2>/dev/null>/dev/null
ifeq ($(BUILD_ENVIRONMENT),gh-pages)
pullfirst = -$(DOCKER) pull $(IMG)
endif
# quick-and-dirty serve, for local use
# We use the dev environment
serve: kill
$(DOCKER) run --rm -it \
$(docker_args) \
-p 8080:8080 \
$(IMG) \
-c "$(DEBUG_FLAGS) ELEVENTY_ENV=development eleventy.sh $(PACKAGE_DIR) $(ELEVENTY_JS_FILE) --serve"
# build static site
build: kill
$(pullfirst)
$(DOCKER) run --pull --rm \
$(docker_args) \
$(IMG) \
-c "$(DEBUG_FLAGS) $(ENVIRO_FLAGS) eleventy.sh $(PACKAGE_DIR) $(ELEVENTY_JS_FILE)"
docker-shell: kill
$(pullfirst)
set -x && $(DOCKER) run --pull --rm -it \
$(docker_args) \
-p 8080:8080 \
$(IMG)
deploy-to-csse: clean site-build
read -p "Do you wish to continue with deploy? (y/n)" yn && \
if [ $$yn != y ]; then exit 1; fi
rsync --progress -P -rlvptz \
--bwlimit=90K out/_site/ teaching:DSA-SWU/WWW/
mount:
sshfs teaching:DSA-SWU/WWW ~/mounts/teaching
meld:
meld out/_site ~/mounts/teaching
clean:
sudo rm -rf out/_site