-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (80 loc) · 2.26 KB
/
Makefile
File metadata and controls
103 lines (80 loc) · 2.26 KB
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
.PHONY: docker-build docker-shell print-build-args \
default build \
print-docker-hub-image kill \
clean
SHELL=bash
default:
echo pass
######
# docker stuff
IMAGE_NAME=phlummox-blog
IMAGE_VERSION=0.1.0
print-image-name:
@echo $(IMAGE_NAME)
print-image-version:
@echo $(IMAGE_VERSION)
###
# eleventy stuff
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=production
#ENVIRO_FLAGS=ELEVENTY_ENV=development
CTR_NAME=eleventy
#MOUNT_PACKAGE= -v $$PWD/package.json:/opt/site/package.json \
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
# quick-and-dirty docker build, for local use
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
pullfirst = -$(DOCKER) pull $(IMG)
# 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 --rm -it \
$(docker_args) \
-p 8080:8080 \
$(IMG)
clean:
sudo rm -rf out/_site
# TODO:
# rss files.
# site currently has, on posts page:
# <link href="https://phlummox.dev/post/index.xml" rel="alternate" type="application/rss+xml" title="phlummox's blog" />
# <link href="https://phlummox.dev/post/index.xml" rel="feed" type="application/rss+xml" title="phlummox's blog" />
# see https://www.npmjs.com/package/@11ty/eleventy-plugin-rss