-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
111 lines (84 loc) · 3.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
.PHONY: build
build:
@echo "==> 🏗 Build Containers"
@docker build -t stemmaweb-middleware ./middleware
@docker compose --env-file .env.prod build
start: build
@echo "==> 🚀 Start"
@docker compose --env-file .env.prod up
down:
@echo "==> 🛑 Stop Containers"
@docker compose down
# Spawns a new shell in the dev docker container
shell:
@echo "==> 🐚 Shell"
@docker exec -it stemmaweb bash
################################################################
# Commands below are for the dockerized development environment
# They are only expected to work inside the docker container
################################################################
build-dev:
@echo "==> 🏗 Build Dev Containers"
@docker compose --env-file .env.dev -f docker-compose.dev.yml build
dev: build-dev
@echo "==> 💻 Development"
@docker compose --env-file .env.dev -f docker-compose.dev.yml up
# The command to be replaced in `stemmaweb-e2e`'s entrypoint
CY_NPM_COMMAND="cy:run"
build-tests:
@echo "==> 🏗 Build Test Containers"
@docker build -t stemmaweb-middleware ./middleware
@CY_NPM_COMMAND=$(CY_NPM_COMMAND) docker compose --env-file .env.test -f docker-compose.test.yml build
build-tests-arm:
@make build-tests CY_NPM_COMMAND="cy:run:arm"
tests: tests-down build-tests
@echo "==> 🧪 Run E2E Tests"
@CY_NPM_COMMAND=$(CY_NPM_COMMAND) ./bin/tests.sh
tests-down:
@echo "==> 🛑 Stop Test Containers"
@CY_NPM_COMMAND=$(CY_NPM_COMMAND) docker compose --env-file .env.test -f docker-compose.test.yml down
tests-arm:
@make tests CY_NPM_COMMAND="cy:run:arm"
install-middleware:
@echo "==> 📦 Install Middleware"
@cd middleware && poetry install && cd -
install-frontend:
@echo "==> 📦 Install Frontend"
@./bin/generate-frontend-env.sh > frontend/www/src/js/env.js
@cd frontend && npm install && cd -
install: install-middleware install-frontend
run-middleware:
@echo "==> 📡 Run Middleware"
@cd middleware && make serve-background && cd -
run-frontend:
@echo "==> 📡 Run Frontend"
@cd frontend && npm run serve:background && cd -
run: run-middleware run-frontend
stop-middleware:
@echo "==> 🛑 Stop Middleware"
@killport 3000 || true
stop-frontend:
@echo "==> 🛑 Stop Frontend"
@killport 5000 || true
stop: stop-middleware stop-frontend
dev-down:
@echo "==> 🛑 Stop Dev Containers"
@docker compose --env-file .env.dev -f docker-compose.dev.yml down
archive-env:
@echo "==> 📦 Archive .env files into env.zip"
@docker compose -f docker-compose.dev.yml run --rm shell bash -c 'zip -r env.zip $$(find . -maxdepth 2 -type f -name "*.env*" ! -name "*.example")'
#################################################################################
# The .env* files need to be encrypted and decrypted inside a Docker container
# to make sure that the same `gpg` version is used on all machines, including CI
#################################################################################
encrypt-env: archive-env
@echo "==> 🔐 Encrypt env.zip"
@docker compose -f docker-compose.dev.yml run --rm shell bash -c 'gpg --version && gpg --quiet --batch --yes --symmetric --cipher-algo AES256 --passphrase="$$(cat env_passphrase)" env.zip'
# Adding `.env.dev stemweb/.env.dev` to create empty files so that the dockerized shell spawns successfully
# (We depend on these files in other services declared in `docker-compose.dev.yml`, but we are not using these here)
# As soon as the shell script runs through, the file will be populated with the decrypted env variables
decrypt-env:
@echo "==> 🔓 Decrypt env.zip"
@touch .env.dev stemweb/.env.dev
@docker compose -f docker-compose.dev.yml run --build --rm shell bash -c 'gpg --version && gpg --quiet --batch --yes --decrypt --passphrase="$$(cat env_passphrase)" --output env.zip env.zip.gpg'
@docker compose -f docker-compose.dev.yml run --rm shell bash -c 'unzip -od . env.zip'