forked from rubra-ai/rubra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (63 loc) · 2.44 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
.PHONY: create-tag
TAG := $(or $(TAG),main)
GITHUB_WORKFLOW := $(or $(GITHUB_WORKFLOW),local)
REGISTRY := $(or $(REGISTRY),index.docker.io)
PLATFORMS := linux/amd64,linux/arm64
BUILDX_FLAGS := --platform $(PLATFORMS) --push
define get_full_tag
$(if $(REGISTRY),$(REGISTRY)/)$(if $(ORG),$(ORG)/)$(if $(REPO),$(REPO)/)$(1):$(TAG)
endef
build_images:
@for dir in ./services/backend/* ./services/frontend/*; do \
if [ -d "$$dir" ] && [ -f "$$dir/Dockerfile" ]; then \
SERVICE=$$(basename $$dir); \
FULL_TAG=$(call get_full_tag,$$SERVICE); \
echo "Building Docker image $$FULL_TAG"; \
docker build -t $$FULL_TAG --build-context core=./core $$dir; \
else \
if [ -d "$$dir" ]; then \
echo "Skipping $$dir, no Dockerfile found."; \
fi \
fi \
done
build_and_push_images:
@if [ -z "$(REGISTRY)" ] || [ -z "$(ORG)" ]; then \
echo "Error: REGISTRY and ORG must be set to push images."; \
exit 1; \
fi
docker buildx create --use
@for dir in ./services/backend/* ./services/frontend/*; do \
if [ -d "$$dir" ] && [ -f "$$dir/Dockerfile" ]; then \
SERVICE=$$(basename $$dir); \
FULL_TAG=$(call get_full_tag,$$SERVICE); \
echo "Pushing Docker image $$FULL_TAG"; \
if [ "$(GITHUB_WORKFLOW)" != "local" ]; then \
BUILDX_CACHE_FLAGS="--cache-from type=gha,scope=$$SERVICE --cache-to type=gha,mode=max,scope=$$SERVICE"; \
else \
BUILDX_CACHE_FLAGS=""; \
fi; \
docker buildx build --build-context core=./core $(BUILDX_FLAGS) $$BUILDX_FLAGS_EXTRA -t $$FULL_TAG $$dir; \
fi \
done
create-tag:
@if [ -z "$(VERSION)" ]; then \
echo "VERSION is not set. Usage: make create-tag VERSION=x.y.z"; \
exit 1; \
fi
$(eval TAURI_VERSION := $(patsubst v%,%,$(VERSION)))
@jq '.package.version = "$(TAURI_VERSION)"' ./tauri/src-tauri/tauri.conf.json > temp.json && mv temp.json ./tauri/src-tauri/tauri.conf.json
@git add ./tauri/src-tauri/tauri.conf.json
@git commit -m "Update version to $(VERSION)"
@git tag -a "$(VERSION)" -m "Release $(VERSION)"
@echo "Tagged version $(VERSION)"
init-docs:
docker run --rm --workdir=/docs -v $${PWD}/docs:/docs node:18-buster yarn install
# Ensure docs build without errors. Makes sure generated docs are in-sync with CLI.
validate-docs:
docker run --rm --workdir=/docs -v $${PWD}/docs:/docs node:18-buster yarn build
if [ -n "$$(git status --porcelain --untracked-files=no)" ]; then \
git status --porcelain --untracked-files=no; \
echo "Encountered dirty repo!"; \
git diff; \
exit 1 \
;fi