-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (113 loc) · 3.8 KB
/
Makefile
File metadata and controls
137 lines (113 loc) · 3.8 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
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
SHELL=/bin/bash -o pipefail
REGISTRY ?= ghcr.io/appscode
BIN ?= website
IMAGE := $(REGISTRY)/$(BIN)
TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
DOCKER_PLATFORMS := linux/amd64 linux/arm64
PLATFORM ?= linux/$(subst x86_64,amd64,$(subst aarch64,arm64,$(shell uname -m)))
VERSION = $(TAG)_$(subst /,_,$(PLATFORM))
container-%:
@$(MAKE) container \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
push-%:
@$(MAKE) push \
--no-print-directory \
PLATFORM=$(subst _,/,$*)
all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS)))
all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS)))
.PHONY: container
container: gen-prod
@echo "container: $(IMAGE):$(VERSION)"
@docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f Dockerfile .
@echo
push: container
@docker push $(IMAGE):$(VERSION)
@echo "pushed: $(IMAGE):$(VERSION)"
@echo
.PHONY: docker-manifest
docker-manifest:
docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM)))
docker manifest push $(IMAGE):$(TAG)
.PHONY: release
release:
@$(MAKE) all-push docker-manifest --no-print-directory
.PHONY: deploy-to-linode
deploy-to-linode:
kubectl set image -n ace deploy/acaas-website website=$(IMAGE):$(VERSION)
kubectl delete pods -n ace -l 'app.kubernetes.io/instance=acaas,app.kubernetes.io/name=website'
.PHONY: run
run:
hugo server --config=config.dev.yaml
PRODUCT ?=
.PHONY: assets
assets: hugo-tools
$(HUGO_TOOLS) docs-aggregator --only-assets
find ./data -name "*.json" -exec sed -i 's/https:\/\/cdn.appscode.com\/images/\/assets\/images/g' {} \;
rm -rf static/files/cluster-api
rm -rf static/files/cluster-api-provider-aws
rm -rf static/files/cluster-api-provider-azure
rm -rf static/files/cluster-api-provider-gcp
rm -rf static/files/products/appscode/aws-marketplace
rm -rf static/files/products/appscode/azure-marketplace
rm -rf static/files/products/appscode/gcp-marketplace
.PHONY: gen
gen:
rm -rf public
hugo --config=config.dev.yaml
.PHONY: qa
qa: gen
firebase use default
firebase deploy
.PHONY: gen-prod
gen-prod:
rm -rf public
hugo --minify --config=config.yaml
# .PHONY: release
# release: gen-prod
# firebase use prod
# firebase deploy
# firebase use default
.PHONY: check-links
check-links:
liche -r public -d http://localhost:1313 -c 10 -p -l -x '^http://localhost:9090$$'
VERSION ?=
# https://stackoverflow.com/a/38982011/244009
.PHONY: set-version
set-version:
@mv firebase.json firebase.bk.json
@jq '(.hosting[] | .redirects[] | .destination) |= sub("\/products\/$(PRODUCT)\/.*\/"; "/products/$(PRODUCT)/$(VERSION)/"; "l")' firebase.bk.json > firebase.json
ASSETS_REPO_URL ?=
.PHONY: set-assets-repo
set-assets-repo:
@mv data/config.json data/config.bk.json
@jq '(.assets | .repoURL) |= "$(ASSETS_REPO_URL)"' data/config.bk.json > data/config.json
@rm -rf data/config.bk.json
HUGO_TOOLS = $(shell pwd)/bin/hugo-tools
.PHONY: hugo-tools
hugo-tools: ## Download hugo-tools locally if necessary.
$(call go-get-tool,$(HUGO_TOOLS),appscodelabs/hugo-tools)
# go-get-tool will 'curl' binary from GH repo $2 with version $3 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
OS=$$(echo `uname`|tr '[:upper:]' '[:lower:]'); \
ARCH=$$(uname -m); \
case $$ARCH in \
armv5*) ARCH="armv5";; \
armv6*) ARCH="armv6";; \
armv7*) ARCH="arm";; \
aarch64) ARCH="arm64";; \
x86) ARCH="386";; \
x86_64) ARCH="amd64";; \
i686) ARCH="386";; \
i386) ARCH="386";; \
esac; \
bin=hugo-tools-$${OS}-$${ARCH}; \
echo "Downloading $${bin}" ;\
mkdir -p $(PROJECT_DIR)/bin; \
curl -fsSL -o $(1) https://github.com/$(2)/releases/latest/download/$${bin}; \
chmod +x $(1); \
}
endef