-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (76 loc) · 3.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
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
root_dir := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
backend_img_sha := $(shell docker images -q localhost:32000/backend-image:latest)
frontend_img_sha := $(shell docker images -q localhost:32000/frontend-image:latest)
kubernetes_namespace := anychat
backend_pod_name := backend-deployment
helm_installation_name := anychat-helm
backend_migrate_static:
docker run -v $(root_dir)/back:/back -it $(backend_img_sha) python3 manage.py makemigrations
docker run -v $(root_dir)/back:/back -it $(backend_img_sha) python3 manage.py migrate
docker run -v $(root_dir)/back:/back -it $(backend_img_sha) python3 manage.py collectstatic --noinput
backend_build:
docker build -t localhost:32000/backend-image:latest -f Dockerfile.back_dev back
$(MAKE) backend_migrate_static
# we have to build the local backend first to extract statics
backend_build_prod:
$(MAKE) backend_build
$(MAKE) backend_migrate_static
docker build -t localhost:32000/backend-image-prod:latest -f Dockerfile.back back
# create the default development admin user
backend_create_dev_admin:
docker run -v $(root_dir)/back:/back -it $(backend_img_sha) python3 manage.py shell --command 'from core.tools import get_or_create_base_admin; get_or_create_base_admin()'
backend_push:
docker push localhost:32000/backend-image:latest
backend_push_prod:
docker push localhost:32000/backend-image-prod:latest
backend_run:
echo "Running backend $(backend_img_sha)"
docker run --init --add-host=host.docker.internal:host-gateway -p 8000:8000 -v "$(root_dir)/back:/back" -it $(backend_img_sha)
backend_build_push:
$(MAKE) backend_build
$(MAKE) backend_push
backend_build_push_prod:
$(MAKE) backend_build_prod
$(MAKE) backend_push_prod
frontend_build:
docker build -t localhost:32000/frontend-image:latest -f Dockerfile.front_dev front
frontend_build_prod:
docker build -t localhost:32000/frontend-image-prod:latest -f Dockerfile.front front
frontend_push:
docker push localhost:32000/frontend-image:latest
frontend_push_prod:
docker push localhost:32000/frontend-image-prod:latest
frontend_run:
docker run --init --add-host=host.docker.internal:host-gateway -p 3000:3000 -v $(root_dir)/front:/front -it $(frontend_img_sha)
frontend_build_push:
$(MAKE) frontend_build
$(MAKE) frontend_push
frontend_build_push_prod:
$(MAKE) frontend_build_prod
$(MAKE) frontend_push_prod
full_build_deploy:
$(MAKE) backend_build_push
$(MAKE) frontend_build_push
start_redis:
docker run -p 6379:6379 redis:5
microk8s_attach_backend:
microk8s kubectl exec --stdin --tty $(backend_pod_name) -n $(kubernetes_namespace) -- sh
microk8s_route_backend_local:
microk8s kubectl port-forward $(backend_pod_name) 8000:8000 -n $(kubernetes_namespace)
microk8s_setup:
microk8s status
microk8s start
microk8s enable helm ingress dns registry
microk8s kubectl create namespace $(kubernetes_namespace)
microk8s_status:
microk8s kubectl get all -n $(kubernetes_namespace)
helm_dry_install:
microk8s helm install --debug $(helm_installation_name) ./helm-chart/ --set rootDir=$(root_dir) --dry-run
helm_install:
microk8s helm install --debug $(helm_installation_name) ./helm-chart/ --set rootDir=$(root_dir)
helm_install_prod:
microk8s helm install --debug $(helm_installation_name) ./helm-chart/ --set rootDir=$(root_dir) --values ./helm-chart/production-values.yaml
helm_install_prod_dry:
microk8s helm install --debug $(helm_installation_name) ./helm-chart/ --set rootDir=$(root_dir) --values ./helm-chart/production-values.yaml --dry-run
helm_uninstall:
microk8s helm uninstall $(helm_installation_name)