-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (69 loc) · 3.3 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
TAG ?= $(shell git symbolic-ref --short -q HEAD | tr '/' '-' | tr '\' '-')-$(shell git describe --tags --long --always --abbrev=8 | tr '/' '-' | tr '\' '-')
ENV ?= dev
REGISTRY = registry.digitalocean.com/replant-world-prod
ifeq ($(ENV), prod)
VITE_API_URL = https://app.replantworld.io/api/
else
VITE_API_URL = https://dev.app.replantworld.ulam.pro/api/
endif
BACKEND_IMAGE_NAME = replant-backend
BACKEND_IMAGE_TAGGED = $(REGISTRY)/$(BACKEND_IMAGE_NAME):$(TAG)
UPLOAD_APP_IMAGE_NAME = replant-upload-app
UPLOAD_APP_IMAGE_TAGGED = $(REGISTRY)/$(UPLOAD_APP_IMAGE_NAME):$(TAG)
MARKETPLACE_APP_IMAGE_NAME = replant-marketplace-app
MARKETPLACE_APP_IMAGE_TAGGED = $(REGISTRY)/$(MARKETPLACE_APP_IMAGE_NAME):$(TAG)
.PHONY: help tag backend upload-app marketplace-app up up-backend down reset logs test-backend admin lint-upload-app lint-marketplace-app push-backend push-upload-app push-marketplace-app deploy build release
help: ## Display commands list with explanation
@grep '^\w.*:\s' Makefile | sed -e s'/: down/: /' -e 's/## //'
tag: ## Display current Docker tag
@echo $(TAG)
backend: ## Build backend Docker image
docker build backend \
--tag $(BACKEND_IMAGE_NAME) \
--tag $(BACKEND_IMAGE_TAGGED)
upload-app: ## Build upload app Docker image
docker build upload-app \
--tag $(UPLOAD_APP_IMAGE_NAME) \
--tag $(UPLOAD_APP_IMAGE_TAGGED)
marketplace-app: ## Build marketplace app Docker image
docker build marketplace-app \
--build-arg VITE_API_URL=$(VITE_API_URL) \
--tag $(MARKETPLACE_APP_IMAGE_NAME) \
--tag $(MARKETPLACE_APP_IMAGE_TAGGED)
up: down ## Run local service containers
@[ -f backend/.env ] || touch backend/.env
docker-compose --profile frontend up --build --remove-orphans
up-backend: down ## Run local service containers (only backend)
@[ -f backend/.env ] || touch backend/.env
docker-compose up --build --remove-orphans
down: ## Shut down service containers
@[ -f backend/.env ] || touch backend/.env
docker-compose down --remove-orphans
reset: down ## Reset local database
rm -rf .postgres-data/
logs: ## Print logs (last 100 and follow) from containers
docker-compose logs --tail 100 -f
test-backend: ## Run tests in backend container
docker run $(BACKEND_IMAGE_NAME) /bin/sh -c './lint.sh -c && pytest'
admin: ## Create super user
docker compose exec api python manage.py createsuperuser
lint-upload-app: ## Lint upload app in container
docker run $(UPLOAD_APP_IMAGE_NAME) npm run lint
lint-marketplace-app: ## Lint marketplace app in container
docker run $(MARKETPLACE_APP_IMAGE_NAME) npm run lint
push-backend: ## Push backend Docker image to registry
docker push $(BACKEND_IMAGE_TAGGED)
push-upload-app: ## Push upload app Docker image to registry
docker push $(UPLOAD_APP_IMAGE_TAGGED)
push-marketplace-app: ## Push marketplace app Docker image to registry
docker push $(MARKETPLACE_APP_IMAGE_TAGGED)
deploy: ## Deploy project to Kubernetes cluster
@echo >&2 "Deploying $(TAG) to $(ENV)"
helm upgrade --install replant-$(ENV) ./helm/ \
--namespace default \
--set image.tag=$(TAG) \
--values ./helm/envs/$(ENV)/values.yaml \
--values ./helm/envs/$(ENV)/vars.yaml \
--values ./helm/envs/$(ENV)/secrets.yaml
build: backend upload-app marketplace-app ## Build project
release: push-backend push-upload-app push-marketplace-app deploy ## Push and deploy project