Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
185 lines (143 loc) · 5.82 KB
/
Copy pathMakefile
File metadata and controls
185 lines (143 loc) · 5.82 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
MAKEFLAGS = --no-print-directory --always-make --silent
MAKE = make $(MAKEFLAGS)
DC = $(shell command -v docker-compose >/dev/null 2>&1 && echo "docker-compose" || echo "docker compose")
# Set DEV_SLOT=1, DEV_SLOT=2, etc. to run multiple instances on different ports
DEV_SLOT ?= 0
dev:
@echo "Booting up backend w/ local db...$(if $(filter-out 0,$(DEV_SLOT)), (slot $(DEV_SLOT)),)"
PORT=$$((8888 + $(DEV_SLOT) * 1000)) \
SSL_PORT=$$((8889 + $(DEV_SLOT) * 1000)) \
NREPL_PORT=$$((6005 + $(DEV_SLOT) * 1000)) \
HZ_PORT=$$((5701 + $(DEV_SLOT) * 1000)) \
clojure -T:build dev
memory-meter-dev:
@echo "Booting up backend w/ local db..."
clojure -T:build memory-meter
bootstrap-oss:
clojure -X:dev:oss-bootstrap
dev-oss:
@echo "Booting up backend w/ local db..."
clojure -X:dev:oss-bootstrap
@echo "Starting server..."
clojure -T:build dev
install-hooks:
@echo "Installing .git/hooks/pre-commit..."
ln -f -s ../../server/dev-resources/hooks/pre-commit ../.git/hooks/pre-commit
docker-compose:
$(DC) -f ./docker-compose-dev.yml build && $(DC) -f ./docker-compose-dev.yml up
dev-up:
@echo "Migrating dev db up to latest"
migrate -database "postgresql://localhost:5432/instant?sslmode=disable" -path resources/migrations up
dev-down:
@echo "Migrating dev db up down by 1"
migrate -database "postgresql://localhost:5432/instant?sslmode=disable" -path resources/migrations down 1
## Generates the blank up/down files for the migration
# Update -digits to 4 after we reach migration 999
create-migration:
@read -p "Enter the migration name: " name; \
migrate create -dir resources/migrations -ext sql -digits 3 -seq "$$name"
compile-java:
clojure -T:build compile-java
test:
TEST=true clojure -M:test
test+:
TEST=true clojure -X:test instant.test-core/-main+
retest:
TEST=true clojure -M:retest
deploy:
./scripts/eb_deploy.clj
manual-deploy:
./scripts/manual_deploy.sh
restart:
@echo "Restarting beanstalk..."
aws elasticbeanstalk restart-app-server --environment-name Instant-prod-env
prod-ssh:
./scripts/prod_ssh.sh
prod-tunnel:
./scripts/prod_tunnel.sh
prod-connect:
clj -M:repl-connect
define migration_source
if [ -n "$$GITHUB_USER" ] && [ -n "$$GITHUB_TOKEN" ]; then \
echo "github://$${GITHUB_USER}:$${GITHUB_TOKEN}@instantdb/instant/server/resources/migrations#main"; \
else \
echo "github://instantdb/instant/server/resources/migrations#main"; \
fi
endef
prod-version:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
SOURCE_URL=$$($(migration_source)); \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" version
prod-up:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
SOURCE_URL=$$($(migration_source)); \
echo "[IMPORTANT] Migrating prod up to latest -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" up
prod-up-one:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
SOURCE_URL=$$($(migration_source)); \
echo "[IMPORTANT] Migrating prod up 1 -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" up 1
prod-down:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
SOURCE_URL=$$($(migration_source)); \
echo "[IMPORTANT] Migrating prod db down by 1 -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" down 1
staging-version:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh --cluster-id "instant-aurora-staging"); \
SOURCE_URL=$$($(migration_source)); \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" version
staging-up:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh --cluster-id "instant-aurora-staging"); \
SOURCE_URL=$$($(migration_source)); \
echo "[IMPORTANT] Migrating staging up to latest -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" up
staging-down:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh --cluster-id "instant-aurora-staging"); \
SOURCE_URL=$$($(migration_source)); \
echo "[IMPORTANT] Migrating staging db down by 1 -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
migrate -verbose -database "$${DATABASE_URL}" -source "$${SOURCE_URL}" down 1
psql:
@echo "Connecting to local db..."
psql -h localhost -d instant
prod-psql:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
echo "[IMPORTANT] Connecting to prod db -- are you sure you want to do this? [y/N]" && \
read ans && [ $$ans = y ] && \
psql "$${DATABASE_URL}"
psql-dump:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
echo "Exporting prod db..." && \
pg_dump "$${DATABASE_URL}" -f dump.sql
psql-dump-dir:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
echo "Exporting prod db..." && \
pg_dump "$${DATABASE_URL}" -F d -j 8 --compress=zstd:3 -f dump-dir && \
echo "Import with \`pg_restore -d LOCAL_DB -j 8 dump-dir\`"
psql-dump-schema:
@DATABASE_URL=$$(./scripts/prod_connection_string.sh); \
echo "Exporting prod db..." && \
pg_dump "$${DATABASE_URL}" --schema-only -f dump.schema.sql
tail-web:
./scripts/tail_web.sh
tail-pg:
aws logs tail /aws/rds/cluster/instant-aurora-1/postgresql --follow
encrypt-secret-dev:
clj -X:encrypt-secret :env :dev
encrypt-secret-prod:
clj -X:encrypt-secret :env :prod
encrypt-secret-staging:
clj -X:encrypt-secret :env :staging
generate-cloudfront-key-dev:
clj -X:generate-cloudfront-key :env :dev
generate-cloudfront-key-prod:
clj -X:generate-cloudfront-key :env :prod
generate-cloudfront-key-staging:
clj -X:generate-cloudfront-key :env :staging
lint:
if command -v clj-kondo >/dev/null 2>&1; then clj-kondo --lint src test; else clojure -M:lint; fi