forked from fluxcd/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
148 lines (124 loc) · 6.17 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Fast NONBlOCKING IO to stdout can
# cause Netlify builds to terminate unexpectantly. This forces stdout to block.
BLOCK_STDOUT_CMD := python -c "import os,sys,fcntl; \
flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); \
fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);"
DOCSY_COMMIT ?= 436ae8700eeb7ea63278b9d1a410ea03d32bf156
DOCSY_COMMIT_FOLDER := docsy-$(DOCSY_COMMIT)
DOCSY_TARGET := themes/$(DOCSY_COMMIT_FOLDER)
GALLERY_COMMIT ?= 3789bdf54e053fccd98f27e1bbdd522b319d4b98
GALLERY_COMMIT_FOLDER := hugo-shortcode-gallery-$(GALLERY_COMMIT)
GALLERY_TARGET := themes/$(GALLERY_COMMIT_FOLDER)
BOOTSTRAP_SEMVER ?= 4.6.1
BOOTSTRAP_SEMVER_FOLDER := bootstrap-$(BOOTSTRAP_SEMVER)
BOOTSTRAP_TARGET := themes/$(DOCSY_COMMIT_FOLDER)/assets/vendor/$(BOOTSTRAP_SEMVER_FOLDER)
FONT_AWESOME_SEMVER ?= 5.15.4
FONT_AWESOME_SEMVER_FOLDER := Font-Awesome-$(FONT_AWESOME_SEMVER)
FONT_AWESOME_TARGET := themes/$(DOCSY_COMMIT_FOLDER)/assets/vendor/$(FONT_AWESOME_SEMVER_FOLDER)
DEV_IMAGE_REGISTRY_NAME ?= fluxcd
HUGO_VERSION ?= $(shell grep HUGO_VERSION netlify.toml | cut -d'"' -f2)
HUGO_IMAGE_BASE_NAME := website:hugo-$(HUGO_VERSION)-extended
SUPPORT_IMAGE_BASE_NAME := website:hugo-support
HUGO_IMAGE_NAME ?= $(DEV_IMAGE_REGISTRY_NAME)/$(HUGO_IMAGE_BASE_NAME)
SUPPORT_IMAGE_NAME ?= $(DEV_IMAGE_REGISTRY_NAME)/$(SUPPORT_IMAGE_BASE_NAME)
HUGO_BIND_ADDRESS ?= 127.0.0.1
BUILDER_CLI := docker
# BUILDER_CLI := okteto
LYCHEE_IMAGE_NAME ?= lycheeverse/lychee:202105190720247e4977
help: ## Display this help menu.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: help
theme: $(DOCSY_TARGET) $(GALLERY_TARGET) $(BOOTSTRAP_TARGET) $(FONT_AWESOME_TARGET) ## Downloads the Docsy theme and dependencies.
$(DOCSY_TARGET): ## Downloads the Docsy theme.
mkdir -p themes/
rm -rf themes/docsy
curl -Lfs "https://github.com/google/docsy/archive/${DOCSY_COMMIT}.tar.gz" -o "/tmp/${DOCSY_COMMIT_FOLDER}.tar.gz"
tar -zxf "/tmp/${DOCSY_COMMIT_FOLDER}.tar.gz" --directory themes/
mv themes/${DOCSY_COMMIT_FOLDER} themes/docsy
ln -sf docsy themes/${DOCSY_COMMIT_FOLDER}
$(GALLERY_TARGET): ## Downloads the hugo-shortcode-gallery theme.
mkdir -p themes/
rm -rf themes/hugo-shortcode-gallery
curl -Lfs "https://github.com/mfg92/hugo-shortcode-gallery/archive/${GALLERY_COMMIT}.tar.gz" -o "/tmp/${GALLERY_COMMIT_FOLDER}.tar.gz"
tar -zxf "/tmp/${GALLERY_COMMIT_FOLDER}.tar.gz" --directory themes/
mv themes/${GALLERY_COMMIT_FOLDER} themes/hugo-shortcode-gallery
ln -sf hugo-shortcode-gallery themes/${GALLERY_COMMIT_FOLDER}
$(BOOTSTRAP_TARGET): ## Downloads the Docsy bootstrap dependency.
mkdir -p themes/docsy/assets/vendor
rm -rf themes/docsy/assets/vendor/bootstrap
curl -Lfs "https://github.com/twbs/bootstrap/archive/v${BOOTSTRAP_SEMVER}.tar.gz" -o "/tmp/bootstrap-${BOOTSTRAP_SEMVER}.tar.gz"
tar -zxf /tmp/bootstrap-${BOOTSTRAP_SEMVER}.tar.gz --directory /tmp
mv /tmp/bootstrap-${BOOTSTRAP_SEMVER} themes/docsy/assets/vendor/bootstrap
ln -sf bootstrap themes/docsy/assets/vendor/bootstrap-${BOOTSTRAP_SEMVER}
$(FONT_AWESOME_TARGET): ## Downloads the Docsy Font Awesome dependency.
mkdir -p themes/docsy/assets/vendor
rm -rf themes/docsy/assets/vendor/Font-Awesome
curl -Lfs "https://github.com/FortAwesome/Font-Awesome/archive/${FONT_AWESOME_SEMVER}.tar.gz" -o "/tmp/Font-Awesome-${FONT_AWESOME_SEMVER}.tar.gz"
tar -zxf /tmp/Font-Awesome-${FONT_AWESOME_SEMVER}.tar.gz --directory /tmp
mv /tmp/Font-Awesome-${FONT_AWESOME_SEMVER} themes/docsy/assets/vendor/Font-Awesome
ln -sf Font-Awesome themes/docsy/assets/vendor/Font-Awesome-${FONT_AWESOME_SEMVER}
gen-content: ## Generates content from external sources.
hack/adopters.py
hack/gen-content.py
hack/import-calendar.py
hack/import-flux2-assets.sh
serve: gen-content theme ## Spawns a development server.
hugo server \
--bind ${HUGO_BIND_ADDRESS} \
--buildDrafts \
--buildFuture \
--disableFastRender
production-build: gen-content theme ## Builds production build.
hugo \
--baseURL $(URL) \
--gc \
--minify \
--enableGitInfo
preview-build: gen-content theme ## Builds a preview build (for e.g. a pull requests).
hugo \
--baseURL $(DEPLOY_PRIME_URL) \
--buildFuture \
--gc \
--minify \
--enableGitInfo
branch-build: gen-content theme ## Builds a Git branch (for e.g. development branches).
hugo \
--baseURL $(DEPLOY_PRIME_URL) \
--buildDrafts \
--buildFuture \
--gc \
--minify \
--enableGitInfo
.PHONY: docker-preview
docker-preview: docker-theme docker-serve
.PHONY: docker-theme
docker-theme:
docker run -v $(shell pwd):/site -it $(SUPPORT_IMAGE_NAME) \
make \"MAKEFLAGS=$(MAKEFLAGS)\" theme
.PHONY: docker-serve
docker-serve:
docker run -v $(shell pwd):/site -p 1313:1313 -it $(SUPPORT_IMAGE_NAME) \
make \"MAKEFLAGS=$(MAKEFLAGS)\" serve HUGO_BIND_ADDRESS=0.0.0.0
.PHONY: docker-push docker-push-hugo docker-push-support
docker-push: docker-push-hugo docker-push-support
docker-push-hugo: docker-build-hugo
$(BUILDER_CLI) push $(HUGO_IMAGE_NAME)
# cd hugo; $(BUILDER_CLI) push -t $(HUGO_IMAGE_NAME)
docker-push-support: docker-build-support
$(BUILDER_CLI) push $(SUPPORT_IMAGE_NAME)
# $(BUILDER_CLI) push -t $(SUPPORT_IMAGE_NAME)
.PHONY: docker-build-support
docker-build-support:
$(BUILDER_CLI) build --build-arg HUGO_VERSION=${HUGO_VERSION} -t $(SUPPORT_IMAGE_NAME) .
.PHONY: docker-build-hugo
docker-build-hugo: hugo
$(BUILDER_CLI) build --build-arg HUGO_VERSION=${HUGO_VERSION} -t $(HUGO_IMAGE_NAME) --build-arg HUGO_BUILD_TAGS=extended hugo/
hugo:
git clone https://github.com/gohugoio/hugo.git --depth 1 -b v$(HUGO_VERSION)
.PHONY: lychee-docker
lychee-docker: gen-content
docker run --rm -it -e "GITHUB_TOKEN=$GITHUB_TOKEN" -v $$(pwd):/app $(LYCHEE_IMAGE_NAME) "/app/**/*.md"
print-hugo-version:
echo hugo_version=$(HUGO_VERSION)
print-repo-owner:
echo repo_owner=$(DEV_IMAGE_REGISTRY_NAME)