-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
119 lines (102 loc) · 4.01 KB
/
Copy pathMakefile
File metadata and controls
119 lines (102 loc) · 4.01 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
# CSSC Dashboard — local development on a kind cluster using the same Helm charts.
#
.DEFAULT_GOAL := help
# Load project-local secrets/config from .env if present (e.g. GITHUB_TOKEN).
# Lines are KEY=value; the file is gitignored. See .env.example.
ifneq (,$(wildcard .env))
include .env
export
endif
CLUSTER ?= cssc-dashboard
NAMESPACE ?= cssc-dashboard
TAG ?= dev
RELEASE ?= cssc
PORT ?= 8000
# Chart source: local path by default; override with the package-repo OCI ref,
# e.g. CHART=oci://ghcr.io/toddysm/charts/cssc-dashboard (run `helm registry
# login ghcr.io` first).
CHART ?= deploy/helm/cssc-dashboard
SERVICES := packages-service issues-service dashboard-web
# App images + base image are sourced from the package repo (GHCR). Override
# BASE_IMAGE (e.g. python:3.14-slim) for local dev if golden is unavailable.
IMAGE_PREFIX ?= ghcr.io/toddysm/apps/cssc-dashboard
BASE_IMAGE ?= ghcr.io/toddysm/golden/python:3.14-slim
VENV := .venv
PIP := $(VENV)/bin/pip
PYTEST := $(VENV)/bin/pytest
.PHONY: help
help:
@echo "CSSC Dashboard — make targets:"
@echo " venv create the local virtualenv and install all packages"
@echo " test run unit tests for the library and all services"
@echo " lint helm lint all charts"
@echo " build build the three service images (docker)"
@echo " kind-up create the kind cluster"
@echo " kind-down delete the kind cluster"
@echo " load load the images into the kind cluster"
@echo " secret create the GitHub token Secret (needs GITHUB_TOKEN)"
@echo " deploy helm upgrade --install the umbrella chart"
@echo " up kind-up + build + load + secret + deploy"
@echo " down delete the kind cluster"
@echo " forward port-forward dashboard-web to localhost:$(PORT)"
# ---------------------------------------------------------------- local python
.PHONY: venv
venv:
python3 -m venv $(VENV)
$(PIP) install --upgrade pip
$(PIP) install -e './libs/cssc_common[test]'
for s in $(SERVICES); do $(PIP) install -e "./services/$$s[test]"; done
.PHONY: test
test:
@set -e; for d in libs/cssc_common $(addprefix services/,$(SERVICES)); do \
echo "== $$d =="; ( cd "$$d" && $(abspath $(PYTEST)) -q ); \
done
# ------------------------------------------------------------------------ helm
.PHONY: lint
lint:
for s in $(SERVICES); do helm lint "services/$$s/deploy/helm/$$s"; done
helm dependency build $(CHART)
helm lint $(CHART)
# ---------------------------------------------------------------------- images
.PHONY: build
build:
for s in $(SERVICES); do \
docker build --build-arg BASE_IMAGE="$(BASE_IMAGE)" \
-f "services/$$s/Dockerfile" -t "$(IMAGE_PREFIX)/$$s:$(TAG)" . ; \
done
# ------------------------------------------------------------------------ kind
.PHONY: kind-up
kind-up:
kind create cluster --name $(CLUSTER)
.PHONY: kind-down
kind-down:
kind delete cluster --name $(CLUSTER)
.PHONY: load
load:
for s in $(SERVICES); do \
kind load docker-image "$(IMAGE_PREFIX)/$$s:$(TAG)" --name $(CLUSTER); \
done
# ---------------------------------------------------------------------- deploy
.PHONY: secret
secret:
@test -n "$(GITHUB_TOKEN)" || { echo "GITHUB_TOKEN is not set"; exit 1; }
kubectl create namespace $(NAMESPACE) --dry-run=client -o yaml | kubectl apply -f -
@# Prefixed with @ so make does not echo the expanded token to the terminal.
@kubectl -n $(NAMESPACE) create secret generic cssc-dashboard-github \
--from-literal=GITHUB_TOKEN=$(GITHUB_TOKEN) \
--dry-run=client -o yaml | kubectl apply -f -
.PHONY: deploy
deploy:
@case "$(CHART)" in oci://*) : ;; *) helm dependency build "$(CHART)" ;; esac
helm upgrade --install $(RELEASE) $(CHART) --namespace $(NAMESPACE) --create-namespace
.PHONY: undeploy
undeploy:
helm uninstall $(RELEASE) --namespace $(NAMESPACE)
.PHONY: up
up: kind-up build load secret deploy
.PHONY: down
down: kind-down
.PHONY: forward
forward:
@echo "Dashboard at http://localhost:$(PORT)"
kubectl -n $(NAMESPACE) port-forward svc/dashboard-web $(PORT):80