-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
166 lines (133 loc) · 4.46 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
.PHONY: help
.DEFAULT_GOAL := help
SAVE_ID="_default"
BOARD_SIZE="7"
PLAYER_COUNT="1"
E2E_NO_HEADLESS="0"
E2E_DEVTOOLS="0"
# This is the hash used to tag Docker images
COMMIT_HASH=$(shell git rev-parse HEAD)
DOCKER_IMAGE_NAMESPACE=jonathanmarmelab
DOCKER_IMAGE_DOMAIN_API=${DOCKER_IMAGE_NAMESPACE}/labyrinth-domain-api
DOCKER_IMAGE_WEBAPP=${DOCKER_IMAGE_NAMESPACE}/labyrinth-webapp
DOCKER_IMAGE_WEBAPP_MIGRATIONS=${DOCKER_IMAGE_NAMESPACE}/labyrinth-webapp-migrations
DOCKER_IMAGE_ADMIN_PROXY=${DOCKER_IMAGE_NAMESPACE}/labyrinth-admin-proxy
DOCKER_IMAGE_PROXY=${DOCKER_IMAGE_NAMESPACE}/labyrinth-proxy
SERVER_USER=""
SERVER_HOSTNAME=""
ifneq (,$(wildcard .secrets/.env))
include .secrets/.env
export
endif
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
setup-env: ## Setup the environment
@(${MAKE} -C webapp setup-env)
install: ## Install dependencies
@(${MAKE} -C domain install)
@(${MAKE} -C webapp install)
run: develop ## Run the program for development, alias of develop
develop: develop-certs ## Run the program for development
@(mkdir -p logs data/postgres)
docker compose \
--env-file webapp/.env \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up --build
develop-daemon: install develop-certs ## Run the program for development as a background service
@(mkdir -p logs data/postgres)
docker compose \
--env-file webapp/.env \
-f docker-compose.yml \
-f docker-compose.dev.yml \
up -d
develop-daemon-stop: develop-certs ## Stops the development background service
@(mkdir -p logs data/postgres)
docker compose \
--env-file webapp/.env \
-f docker-compose.yml \
-f docker-compose.dev.yml \
down
develop-certs:
@(./scripts/dev-certs.sh)
develop-config: ## Dumps the docker development compose file with environment set
docker compose \
--env-file webapp/.env \
-f docker-compose.yml \
-f docker-compose.dev.yml \
config
production-image-build:
echo "Building images using hash: ${COMMIT_HASH}"
docker build \
-f domain/api/Dockerfile \
-t ${DOCKER_IMAGE_DOMAIN_API}:${COMMIT_HASH} \
-t ${DOCKER_IMAGE_DOMAIN_API}:latest \
.
docker build \
-f admin-proxy/Dockerfile \
-t ${DOCKER_IMAGE_ADMIN_PROXY}:${COMMIT_HASH} \
-t ${DOCKER_IMAGE_ADMIN_PROXY}:latest \
.
docker build \
-f webapp/Dockerfile \
-t ${DOCKER_IMAGE_WEBAPP}:${COMMIT_HASH} \
-t ${DOCKER_IMAGE_WEBAPP}:latest \
.
docker build \
-f webapp/migrations/Dockerfile \
-t ${DOCKER_IMAGE_WEBAPP_MIGRATIONS}:${COMMIT_HASH} \
-t ${DOCKER_IMAGE_WEBAPP_MIGRATIONS}:latest \
.
docker build \
-f proxy/production/Dockerfile \
-t ${DOCKER_IMAGE_PROXY}:${COMMIT_HASH} \
-t ${DOCKER_IMAGE_PROXY}:latest \
.
production-image-push: production-image-build ## Push production images to Docker Hub
docker image push --all-tags ${DOCKER_IMAGE_DOMAIN_API}
docker image push --all-tags ${DOCKER_IMAGE_WEBAPP}
docker image push --all-tags ${DOCKER_IMAGE_WEBAPP_MIGRATIONS}
docker image push --all-tags ${DOCKER_IMAGE_ADMIN_PROXY}
docker image push --all-tags ${DOCKER_IMAGE_PROXY}
production-deploy: production-image-push ## Deploy production to AWS
scp \
-o StrictHostKeyChecking=no \
-i .secrets/labyrinth-ed25519.pem \
docker-compose.yml docker-compose.prod.yml scripts/run-production.sh \
${SERVER_USER}@${SERVER_HOSTNAME}:~
ssh \
-o StrictHostKeyChecking=no \
-i .secrets/labyrinth-ed25519.pem \
${SERVER_USER}@${SERVER_HOSTNAME} \
'echo "TAG=${COMMIT_HASH}" > .env'
ssh \
-o StrictHostKeyChecking=no \
-i .secrets/labyrinth-ed25519.pem \
${SERVER_USER}@${SERVER_HOSTNAME} \
'./run-production.sh'
production: production-image-build
docker compose \
--env-file=webapp/.env \
-f docker-compose.yml \
-f docker-compose.prod.yml \
up
production-ssh-test:
ssh -T \
-o StrictHostKeyChecking=no \
-i .secrets/labyrinth-ed25519.pem \
${SERVER_USER}@${SERVER_HOSTNAME} \
exit
test: ## Run unit tests
@(${MAKE} -C domain test)
@(${MAKE} -C mobile test)
@(${MAKE} -C webapp test)
test-e2e: ## Run e2e tests
@(cp -n cypress.env.dist cypress.env)
@(npm install)
@(npm run cypress:e2e)
cli-run: ## Run the CLI version of the labyrinth.
@(${MAKE} -C domain run)
cli-clean: ## Cleans all existing saves, use with caution.
@(rm ${HOME}/.labyrinth/*)
ai-train: ## Train the AI
@(${MAKE} -C domain ai-train)