-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
101 lines (74 loc) · 2.23 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
##################
## docker commands
##################
DOCKER := docker
ifeq ($(shell uname -s),Linux)
DOCKER := sudo docker
endif
COMPOSE=$(DOCKER) compose
.PHONY: build up server dev monitor all clean down down-with-volumes
build:
$(COMPOSE) --profile server build
up:
$(COMPOSE) up -d
server: build
$(COMPOSE) --profile server up -d
dev:
$(COMPOSE) --profile dev up -d
monitor: build
$(COMPOSE) --profile monitoring --profile server up -d
all: build
$(COMPOSE) --profile "*" up -d
clean:
$(DOCKER) system prune -a
down:
$(COMPOSE) --profile "*" down --remove-orphans
down-with-volumes:
$(COMPOSE) --profile "*" down -v --remove-orphans
##################
## go tool commands
##################
GFLAGS=-tags=jsoniter
GVARS=GOEXPERIMENT=rangefunc
GORUN=$(GVARS) go run $(GFLAGS)
.PHONY: fmt run help test scrape dump backfill
fmt:
go mod tidy
go fmt ./...
go vet ./...
run: fmt
$(GORUN) ./cmd server
help: fmt
$(GORUN) ./cmd --help
test: fmt
go test -short ./...
# TODO(zeke): use the running container, but add a new database?
test-db: fmt
go test -short -tags=integration ./internal/metacritic
#atlas schema clean -u "postgres://zeke:reyna@localhost:5432/integration?sslmode=disable" --auto-approve
#atlas schema apply -u "postgres://zeke:reyna@localhost:5432/integration?sslmode=disable" --to file://schema.sql \
# --auto-approve \
# --dev-url "postgres://atlas:pass@localhost:5444/postgres?sslmode=disable"
# # spin up postgres db
# docker run --name postgres-integration -e POSTGRES_USER=zeke -e POSTGRES_PASSWORD=reyna -e POSTGRES_DB=integration
scrape:
$(GORUN) ./cmd scrape reddit
dump:
$(GORUN) ./cmd dump
backfill:
CREDS=--username=$ZEST_USERNAME --password=$ZEST_PASSWORD
#$(GORUN) ./cmd backfill --help
#$(GORUN) ./cmd backfill --resource=reddit $(CREDS)
$(GORUN) ./cmd backfill --resource=spotify $(CREDS) \
--start=2024-04-04 --end=2024-05-28
##################
## deploy commands
##################
.PHONY: deploy serverless
deploy: build
$(DOCKER) save zest-backend-zest-api > zest-api.tar
scp zest-api.tar droplet:~/workspace/zest-api.tar
ssh droplet 'make -C workspace deploy'
serverless:
doctl serverless deploy serverless/digitalocean
# can also test with doctl serverless functions invoke zest/refresh