-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
268 lines (201 loc) · 12.8 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
IMAGE_REPOSITORY = localhost:5001
PACKAGE_VERSION = latest
RELEASE_VERSION = 0.0.1
UNAME_SYSTEM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
UNAME_MACHINE := $(shell uname -m)
DOCKER_PLATFORM = linux/amd64
TARGET_SYSTEM = $(UNAME_SYSTEM)
TARGET_MACHINE = $(UNAME_MACHINE)
ifeq ($(UNAME_MACHINE),x86_64)
TARGET_MACHINE = amd64
endif
TARGET_PLATFORM = $(TARGET_SYSTEM)-$(TARGET_MACHINE)
DOCKER_PLATFORM = linux/$(TARGET_MACHINE)
all: push-all-images # deploy-installer deploy-workshop
build-all-images: build-session-manager build-training-portal \
build-base-environment build-jdk8-environment build-jdk11-environment \
build-jdk17-environment build-jdk21-environment \
build-conda-environment build-docker-registry \
build-pause-container build-secrets-manager build-tunnel-manager \
build-image-cache build-assets-server build-lookup-service
push-all-images: push-session-manager push-training-portal \
push-base-environment push-jdk8-environment push-jdk11-environment \
push-jdk17-environment push-jdk21-environment \
push-conda-environment push-docker-registry \
push-pause-container push-secrets-manager push-tunnel-manager \
push-image-cache push-assets-server push-lookup-service
build-core-images: build-session-manager build-training-portal \
build-base-environment build-docker-registry build-pause-container \
build-secrets-manager build-tunnel-manager build-image-cache \
build-assets-server
push-core-images: push-session-manager push-training-portal \
push-base-environment push-docker-registry push-pause-container \
push-secrets-manager push-tunnel-manager push-image-cache \
push-assets-server
build-session-manager:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-session-manager:$(PACKAGE_VERSION) session-manager
push-session-manager: build-session-manager
docker push $(IMAGE_REPOSITORY)/educates-session-manager:$(PACKAGE_VERSION)
build-training-portal:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-training-portal:$(PACKAGE_VERSION) training-portal
push-training-portal: build-training-portal
docker push $(IMAGE_REPOSITORY)/educates-training-portal:$(PACKAGE_VERSION)
build-base-environment:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-base-environment:$(PACKAGE_VERSION) workshop-images/base-environment
push-base-environment: build-base-environment
docker push $(IMAGE_REPOSITORY)/educates-base-environment:$(PACKAGE_VERSION)
build-jdk8-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk8-environment:$(PACKAGE_VERSION) workshop-images/jdk8-environment
push-jdk8-environment: build-jdk8-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk8-environment:$(PACKAGE_VERSION)
build-jdk11-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk11-environment:$(PACKAGE_VERSION) workshop-images/jdk11-environment
push-jdk11-environment: build-jdk11-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk11-environment:$(PACKAGE_VERSION)
build-jdk17-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk17-environment:$(PACKAGE_VERSION) workshop-images/jdk17-environment
push-jdk17-environment: build-jdk17-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk17-environment:$(PACKAGE_VERSION)
build-jdk21-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-jdk21-environment:$(PACKAGE_VERSION) workshop-images/jdk21-environment
push-jdk21-environment: build-jdk21-environment
docker push $(IMAGE_REPOSITORY)/educates-jdk21-environment:$(PACKAGE_VERSION)
build-conda-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-conda-environment:$(PACKAGE_VERSION) workshop-images/conda-environment
push-conda-environment: build-conda-environment
docker push $(IMAGE_REPOSITORY)/educates-conda-environment:$(PACKAGE_VERSION)
build-desktop-environment: build-base-environment
docker build --progress plain --platform $(DOCKER_PLATFORM) --build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) -t $(IMAGE_REPOSITORY)/educates-desktop-environment:$(PACKAGE_VERSION) workshop-images/desktop-environment
push-desktop-environment: build-desktop-environment
docker push $(IMAGE_REPOSITORY)/educates-desktop-environment:$(PACKAGE_VERSION)
build-docker-registry:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-docker-registry:$(PACKAGE_VERSION) docker-registry
push-docker-registry: build-docker-registry
docker push $(IMAGE_REPOSITORY)/educates-docker-registry:$(PACKAGE_VERSION)
build-pause-container:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-pause-container:$(PACKAGE_VERSION) pause-container
push-pause-container: build-pause-container
docker push $(IMAGE_REPOSITORY)/educates-pause-container:$(PACKAGE_VERSION)
build-secrets-manager:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-secrets-manager:$(PACKAGE_VERSION) secrets-manager
push-secrets-manager: build-secrets-manager
docker push $(IMAGE_REPOSITORY)/educates-secrets-manager:$(PACKAGE_VERSION)
build-tunnel-manager:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-tunnel-manager:$(PACKAGE_VERSION) tunnel-manager
push-tunnel-manager: build-tunnel-manager
docker push $(IMAGE_REPOSITORY)/educates-tunnel-manager:$(PACKAGE_VERSION)
build-image-cache:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-image-cache:$(PACKAGE_VERSION) image-cache
push-image-cache: build-image-cache
docker push $(IMAGE_REPOSITORY)/educates-image-cache:$(PACKAGE_VERSION)
build-assets-server:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-assets-server:$(PACKAGE_VERSION) assets-server
push-assets-server: build-assets-server
docker push $(IMAGE_REPOSITORY)/educates-assets-server:$(PACKAGE_VERSION)
build-lookup-service:
docker build --progress plain --platform $(DOCKER_PLATFORM) -t $(IMAGE_REPOSITORY)/educates-lookup-service:$(PACKAGE_VERSION) lookup-service
push-lookup-service: build-lookup-service
docker push $(IMAGE_REPOSITORY)/educates-lookup-service:$(PACKAGE_VERSION)
verify-installer-config:
ifneq ("$(wildcard developer-testing/educates-installer-values.yaml)","")
@ytt --file carvel-packages/installer/bundle/config --data-values-file developer-testing/educates-installer-values.yaml
else
@echo "No values file found. Please create developer-testing/educates-installer-values.yaml"
exit 1
endif
push-installer-bundle:
ytt -f carvel-packages/installer/config/images.yaml -f carvel-packages/installer/config/schema.yaml -v imageRegistry.host=$(IMAGE_REPOSITORY) -v version=$(PACKAGE_VERSION) > carvel-packages/installer/bundle/kbld/kbld-images.yaml
# For local development, we just need to lock educates images. Everything else can be referenced by tag from real origin.
cat carvel-packages/installer/bundle/kbld/kbld-images.yaml | kbld -f - --imgpkg-lock-output carvel-packages/installer/bundle/.imgpkg/images.yml
imgpkg push -b $(IMAGE_REPOSITORY)/educates-installer:$(RELEASE_VERSION) -f carvel-packages/installer/bundle
mkdir -p developer-testing
ytt -f carvel-packages/installer/config/app.yaml -f carvel-packages/installer/config/schema.yaml -v imageRegistry.host=$(IMAGE_REPOSITORY) -v version=$(RELEASE_VERSION) > developer-testing/educates-installer-app.yaml
deploy-platform:
ifneq ("$(wildcard developer-testing/educates-installer-values.yaml)","")
ytt --file carvel-packages/installer/bundle/config --data-values-file developer-testing/educates-installer-values.yaml | kapp deploy -a label:installer=educates-installer.app -f - -y
else
@echo "No values file found. Please create developer-testing/educates-installer-values.yaml"
exit 1
endif
delete-platform:
kapp delete -a label:installer=educates-installer.app -y
deploy-platform-app: push-installer-bundle
ifeq ("$(wildcard developer-testing/educates-installer-values.yaml)","")
@echo "No values file found. Please create developer-testing/educates-installer-values.yaml"
exit 1
endif
-kubectl apply -f carvel-packages/installer/config/rbac.yaml
kubectl create secret generic educates-installer --from-file=developer-testing/educates-installer-values.yaml -o yaml --dry-run=client | kubectl apply -n educates-installer -f -
kubectl apply --namespace educates-installer -f developer-testing/educates-installer-app.yaml
delete-platform-app:
kubectl delete --namespace educates-installer -f developer-testing/educates-installer-app.yaml
-kubectl delete secret educates-installer -n educates-installer
-kubectl delete -f carvel-packages/installer/config/rbac.yaml
restart-training-platform:
kubectl rollout restart deployment/secrets-manager -n educates
kubectl rollout restart deployment/session-manager -n educates
client-programs-educates:
rm -rf client-programs/pkg/renderer/files
mkdir client-programs/pkg/renderer/files
mkdir -p client-programs/bin
cp -rp workshop-images/base-environment/opt/eduk8s/etc/themes client-programs/pkg/renderer/files/
(cd client-programs; go build -gcflags=all="-N -l" -o bin/educates-$(TARGET_PLATFORM) cmd/educates/main.go)
build-client-programs: client-programs-educates
push-client-programs : build-client-programs
ifeq ($(UNAME_SYSTEM),darwin)
(cd client-programs; GOOS=linux GOARCH=amd64 go build -o bin/educates-linux-amd64 cmd/educates/main.go)
(cd client-programs; GOOS=linux GOARCH=arm64 go build -o bin/educates-linux-arm64 cmd/educates/main.go)
endif
ifeq ($(UNAME_SYSTEM),linux)
ifeq ($(TARGET_PLATFORM),arm64)
(cd client-programs; GOOS=linux GOARCH=amd64 go build -o bin/educates-linux-amd64 cmd/educates/main.go)
endif
ifeq ($(TARGET_PLATFORM),amd64)
(cd client-programs; GOOS=linux GOARCH=arm64 go build -o bin/educates-linux-arm64 cmd/educates/main.go)
endif
endif
imgpkg push -i $(IMAGE_REPOSITORY)/educates-client-programs:$(PACKAGE_VERSION) -f client-programs/bin
build-docker-extension : push-client-programs
$(MAKE) -C docker-extension build-extension REPOSITORY=$(IMAGE_REPOSITORY) TAG=$(PACKAGE_VERSION)
install-docker-extension : build-docker-extension
$(MAKE) -C docker-extension install-extension REPOSITORY=$(IMAGE_REPOSITORY) TAG=$(PACKAGE_VERSION)
update-docker-extension : build-docker-extension
$(MAKE) -C docker-extension update-extension REPOSITORY=$(IMAGE_REPOSITORY) TAG=$(PACKAGE_VERSION)
project-docs/venv :
python3 -m venv project-docs/venv
project-docs/venv/bin/pip install -r project-docs/requirements.txt
build-project-docs : project-docs/venv
source project-docs/venv/bin/activate && make -C project-docs html
open-project-docs :
open project-docs/_build/html/index.html || \
xdg-open project-docs/_build/html/index.html
clean-project-docs:
rm -rf project-docs/venv
rm -rf project-docs/_build
deploy-workshop:
kubectl apply -f https://github.com/educates/lab-k8s-fundamentals/releases/download/7.4/workshop.yaml
kubectl apply -f https://github.com/educates/lab-k8s-fundamentals/releases/download/7.4/trainingportal.yaml
STATUS=1; ATTEMPTS=0; ROLLOUT_STATUS_CMD="kubectl rollout status deployment/training-portal -n lab-k8s-fundamentals-ui"; until [ $$STATUS -eq 0 ] || $$ROLLOUT_STATUS_CMD || [ $$ATTEMPTS -eq 5 ]; do sleep 5; $$ROLLOUT_STATUS_CMD; STATUS=$$?; ATTEMPTS=$$((ATTEMPTS + 1)); done
delete-workshop:
-kubectl delete trainingportal,workshop lab-k8s-fundamentals --cascade=foreground
open-workshop:
URL=`kubectl get trainingportal/lab-k8s-fundamentals -o go-template={{.status.educates.url}}`; (test -x /usr/bin/xdg-open && xdg-open $$URL) || (test -x /usr/bin/open && open $$URL) || true
prune-images:
docker image prune --force
prune-docker:
docker system prune --force
prune-builds:
rm -rf workshop-images/base-environment/opt/gateway/build
rm -rf workshop-images/base-environment/opt/gateway/node_modules
rm -rf workshop-images/base-environment/opt/helper/node_modules
rm -rf workshop-images/base-environment/opt/helper/out
rm -rf workshop-images/base-environment/opt/renderer/build
rm -rf workshop-images/base-environment/opt/renderer/node_modules
rm -rf training-portal/venv
rm -rf client-programs/bin
rm -rf client-programs/pkg/renderer/files
rm -rf project-docs/venv
rm -rf project-docs/_build
prune-registry:
docker exec educates-registry registry garbage-collect /etc/docker/registry/config.yml --delete-untagged=true
prune-all: prune-docker prune-builds prune-registry