-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
94 lines (71 loc) · 2.26 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
-include .env
export $(shell sed 's/=.*//' .env)
LATEST_DUMP=/tmp/dump_latest.gz
BACKUP?=dump_latest.gz
.ONESHELL:
api:
docker-compose up -d db
cd cmd/api && go run -tags=jsoniter .
indexer:
docker-compose up -d db
cd cmd/indexer && go run .
seo:
ifeq ($(BCD_ENV), development)
cd scripts/nginx && go run .
else
docker-compose exec api seo
docker-compose restart gui
endif
migration:
ifeq ($(BCD_ENV), development)
cd scripts/migration && go run .
else
docker-compose exec api migration
endif
rollback:
ifeq ($(BCD_ENV), development)
cd scripts/bcdctl && go run . rollback -n $(NETWORK) -l $(LEVEL)
else
docker-compose exec api bcdctl rollback -n $(NETWORK) -l $(LEVEL)
endif
s3-db-restore:
echo "Database restore..."
ifeq (,$(wildcard $(LATEST_DUMP)))
aws s3 cp --profile bcd s3://bcd-db-snaps/$(BACKUP) $(LATEST_DUMP)
endif
docker-compose exec -T db dropdb -U $(POSTGRES_USER) --if-exists $(POSTGRES_DB)
gunzip -dc $(LATEST_DUMP) | docker-compose exec -T db psql -U $(POSTGRES_USER) -v ON_ERROR_STOP=on $(POSTGRES_DB)
rm $(LATEST_DUMP)
s3-db-snapshot:
echo "Database snapshot..."
docker-compose exec db pg_dump $(POSTGRES_DB) --create -U $(POSTGRES_USER) | gzip -c > $(LATEST_DUMP)
aws s3 mv --profile bcd $(LATEST_DUMP) s3://bcd-db-snaps/dump_latest.gz
s3-list:
echo "Database snapshots"
aws s3 ls --profile bcd s3://bcd-db-snaps
test:
go test ./...
lint:
golangci-lint run
test-api:
# to install newman:
# npm install -g newman
newman run ./scripts/newman/tests.json -e ./scripts/newman/env.json
stable:
TAG=master docker-compose up -d api indexer
db-dump:
docker-compose exec db pg_dump -c $(POSTGRES_DB) > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql
db-restore:
docker-compose exec -T db psql --username $(POSTGRES_USER) -v ON_ERROR_STOP=on $(POSTGRES_DB) < $(BACKUP)
ps:
docker ps --format "table {{.Names}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}"
sandbox-pull:
TAG=4.7.6 docker-compose -f docker-compose.flextesa.yml pull
flextesa-sandbox:
COMPOSE_PROJECT_NAME=bcdbox TAG=4.7.6 docker-compose -f docker-compose.flextesa.yml up -d
sandbox-down:
COMPOSE_PROJECT_NAME=bcdbox docker-compose -f docker-compose.flextesa.yml down
sandbox-clear:
COMPOSE_PROJECT_NAME=bcdbox docker-compose -f docker-compose.flextesa.yml down -v
generate:
go generate ./...