/
Makefile
98 lines (73 loc) · 2.75 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
CWD=$(shell pwd)
GOMOD=$(shell test -f "go.work" && echo "readonly" || echo "vendor")
LDFLAG=-s -w
cli:
go build -mod $(GOMOD) -ldflags="$(LDFLAGS)" -o bin/wof-spelunker-httpd cmd/httpd/main.go
# Targets for running the Spelunker locally
# https://github.com/whosonfirst/go-whosonfirst-opensearch
OS_INDEX=/usr/local/whosonfirst/go-whosonfirst-opensearch/bin/wof-opensearch-index
# https://github.com/whosonfirst/whosonfirst-opensearch
WHOSONFIRST_OPENSEARCH=/usr/local/whosonfirst/whosonfirst-opensearch
# https://github.com/aaronland/go-tools
URLESCAPE=$(shell which urlescape)
# CACHE_URI=gocache://
CACHE_URI=ristretto://
ENC_CACHE_URI=$(shell $(URLESCAPE) $(CACHE_URI))
DSN="https://localhost:9200/spelunker?username=admin&password=dkjfhsjdkfkjdjhksfhskd98475kjHkzjxckj&insecure=true&require-tls=true&cache-uri=$(ENC_CACHE_URI)"
ENC_DSN=$(shell $(URLESCAPE) $(DSN))
SPELUNKER_URI=opensearch://?dsn=$(ENC_DSN)
# Opensearch server
# This is for debugging. Do not change this at your own risk.
# (That means you should change this.)
OS_PSWD=dkjfhsjdkfkjdjhksfhskd98475kjHkzjxckj
# https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/
#
# And then:
# curl -v -k https://admin:$(OS_PSWD)@localhost:9200/
opensearch-local:
docker run \
-it \
-p 9200:9200 \
-p 9600:9600 \
-e "discovery.type=single-node" \
-e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=$(OS_PSWD)" \
-v opensearch-data1:/usr/local/data/opensearch \
opensearchproject/opensearch:latest
# Opensearch "spelunker" index
spelunker-local:
@make spelunker-local-index
@make spelunker-local-fieldlimit
spelunker-local-index:
cat $(WHOSONFIRST_OPENSEARCH)/schema/2.x/mappings.spelunker.json | \
curl -k \
-H 'Content-Type: application/json' \
-X PUT \
https://admin:$(OS_PSWD)@localhost:9200/spelunker \
-d @-
spelunker-local-fieldlimit:
cat $(WHOSONFIRST_OPENSEARCH)/schema/2.x/settings.spelunker.json | \
curl -k \
-H 'Content-type:application/json' \
-XPUT \
https://admin:$(OS_PSWD)@localhost:9200/spelunker/_settings \
-d @-
# Opensearch indexing
index-local:
$(OS_INDEX) \
-writer-uri 'constant://?val=opensearch2%3A%2F%2Flocalhost%3A9200%2Fspelunker%3Frequire-tls%3Dtrue%26insecure%3Dtrue%26debug%3Dfalse%26username%3Dadmin%26password%3D$(OS_PSWD)' \
$(REPO)
# Spelunker server
server-local:
go run -mod $(GOMOD) cmd/httpd/main.go \
-server-uri http://localhost:8080 \
-spelunker-uri '$(SPELUNKER_URI)' \
-protomaps-api-key '$(APIKEY)'
# Lambda stuff
lambda:
@make lambda-server
lambda-server:
if test -f bootstrap; then rm -f bootstrap; fi
if test -f server.zip; then rm -f server.zip; fi
GOARCH=arm64 GOOS=linux go build -mod $(GOMOD) -ldflags="$(LDFLAGS)" -tags lambda.norpc -o bootstrap cmd/httpd/main.go
zip server.zip bootstrap
rm -f bootstrap