-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (94 loc) · 3.12 KB
/
Makefile
File metadata and controls
102 lines (94 loc) · 3.12 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
IMG_NAME = "ghcr.io/libertech-fr/sesame-deamon"
BASE_NAME = "sesame"
APP_NAME = "sesame-daemon"
PLATFORM = "linux/amd64"
PKG_TARGETS = "linux,macos,win"
include .env
.DEFAULT_GOAL := help
help:
@printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n"
@grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}'
build: ## Build the container
@docker build --platform $(PLATFORM) -t $(IMG_NAME) --no-cache .
dev: ## Start development environment
@docker run --rm -it \
-e NODE_ENV=development \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
--add-host host.docker.internal:host-gateway \
--network dev \
--platform $(PLATFORM) \
--name $(APP_NAME) \
-v $(CURDIR):/data \
$(IMG_NAME) yarn start:dev
install: ## Install dependencies
@docker run -it --rm \
-e NODE_ENV=development \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
--add-host host.docker.internal:host-gateway \
--platform $(PLATFORM) \
--network dev \
-v $(CURDIR):/data \
$(IMG_NAME) yarn install
exec: ## Run a shell in the container
@docker run -it --rm \
-e NODE_ENV=development \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
--add-host host.docker.internal:host-gateway \
--platform $(PLATFORM) \
--network dev \
-v $(CURDIR):/data \
$(IMG_NAME) bash
pkg: ## Package the application
@rm sesame-daemon-* || true
@docker run -it --rm \
-e NODE_ENV=development \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
--add-host host.docker.internal:host-gateway \
--platform $(PLATFORM) \
--network dev \
-v $(CURDIR):/data \
$(IMG_NAME) yarn build
@docker run -it --rm \
-e NODE_ENV=development \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
--add-host host.docker.internal:host-gateway \
--platform $(PLATFORM) \
--network dev \
-v $(CURDIR):/data \
$(IMG_NAME) pkg dist/main.js -o sesame-daemon-macos --targets $(PKG_TARGETS) --config package.json
dbs: ## Start databases
@docker volume create $(BASE_NAME)-mongodb
@docker run -d --rm \
--name $(BASE_NAME)-mongodb \
-v $(BASE_NAME)-mongodb:/data/db \
-p 27017:27017 \
-e MONGODB_REPLICA_SET_MODE=primary \
-e MONGODB_REPLICA_SET_NAME=rs0 \
-e ALLOW_EMPTY_PASSWORD=yes \
--platform $(PLATFORM) \
--network dev \
--health-interval=5s \
--health-timeout=3s \
--health-start-period=5s \
--health-retries=3 \
--health-cmd="mongosh --eval \"db.stats().ok\" || exit 1" \
mongo:7.0 --replSet rs0 --wiredTigerCacheSizeGB 1.5 || true
@docker volume create $(BASE_NAME)-redis
@docker run -d --rm \
--name $(BASE_NAME)-redis \
-v $(BASE_NAME)-redis:/data \
--platform $(PLATFORM) \
--network dev \
-p 6379:6379 \
--health-interval=5s \
--health-timeout=3s \
--health-start-period=5s \
--health-retries=3 \
--health-cmd="redis-cli ping || exit 1" \
redis redis-server --appendonly yes || true
@docker exec -it $(BASE_NAME)-mongodb mongosh --eval "rs.initiate({_id: 'rs0', members: [{_id: 0, host: '127.0.0.1:27017'}]})" || true
stop: ## Stop the container
@docker stop $(APP_NAME) || true
@docker stop $(BASE_NAME)-mongodb || true
@docker stop $(BASE_NAME)-redis || true