-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (59 loc) · 2.52 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
REGISTRY := ghcr.io
REPO := nicklasfrahm/infrastructure
TARGET ?= metal
SOURCES := $(shell find . -name "*.go")
PLATFORM ?= $(shell go version | cut -d " " -f 4)
GOOS := $(shell echo $(PLATFORM) | cut -d "/" -f 1)
GOARCH := $(shell echo $(PLATFORM) | cut -d "/" -f 2)
SUFFIX := $(GOOS)-$(GOARCH)
VERSION ?= $(shell git describe --always --tags --dirty)
BUILD_FLAGS := -ldflags="-s -w -X main.version=$(VERSION)"
ifeq ($(GOOS),windows)
SUFFIX = $(GOOS)-$(GOARCH).exe
endif
BINARY ?= bin/$(TARGET)-$(SUFFIX)
build: bin/$(TARGET)-$(SUFFIX)
bin/$(TARGET)-$(SUFFIX): $(SOURCES)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build $(BUILD_FLAGS) -o $(BINARY) cmd/$(TARGET)/*.go
.PHONY: docker
docker:
docker build \
-t $(TARGET):latest \
-t $(TARGET):$(VERSION) \
-t $(REPO)-$(TARGET):latest \
-t $(REPO)-$(TARGET):$(VERSION) \
-t $(REGISTRY)/$(REPO)-$(TARGET):latest \
-t $(REGISTRY)/$(REPO)-$(TARGET):$(VERSION) \
--build-arg TARGET=$(TARGET) \
--build-arg VERSION=$(VERSION) \
-f build/package/Dockerfile .
.PHONY: docker-push
docker-push: docker
docker push $(REGISTRY)/$(REPO)-$(TARGET):$(VERSION)
docker push $(REGISTRY)/$(REPO)-$(TARGET):latest
.PHONY: deploy
deploy: docker-push
sed -i "s|image: .*|image: $(REGISTRY)/$(REPO)-$(TARGET):$(VERSION)|" deploy/kubectl/api/$(TARGET).yaml
kubectl apply -n api -f deploy/kubectl/api/$(TARGET).yaml
git reset --hard
.PHONY: edge
edge: bin/nofip-$(SUFFIX)
@for SITE in alfa bravo charlie ; do \
echo "\033[0;31m>> $$SITE\033[0m" ; \
kubectl --context $$SITE create namespace edge --dry-run=client -o yaml | kubectl apply --server-side -f - ; \
helm --kube-context $$SITE -n edge upgrade --install --atomic edge charts/edge ; \
done
@./bin/nofip-$(SUFFIX) -r edge.nicklasfrahm.dev -e alfa.nicklasfrahm.dev,bravo.nicklasfrahm.dev,charlie.nicklasfrahm.dev
.PHONY: kuard
kuard:
kubectl --context moos create namespace kuard --dry-run=client -o yaml | kubectl apply --server-side -f -
kubectl --context moos -n kuard apply -f deploy/kubectl/kuard
.PHONY: odance
odance:
kubectl --context moos create namespace odance-prd --dry-run=client -o yaml | kubectl --context moos apply --server-side -f -
kubectl --context moos -n odance-prd apply -f secret-odance-prd.yaml
kubectl --context moos -n odance-prd apply -f deploy/kubectl/odance/prd.yaml
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update bitnami
helm --kube-context moos -n odance-prd upgrade --install --atomic odance bitnami/wordpress -f deploy/helm/odance.values.yaml