-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (65 loc) · 2.5 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
SHELL = /bin/bash
# Just to be sure, add the path of the binary-based go installation.
PATH := /usr/local/go/bin:$(PATH)
# Using the (above extended) path, query the GOPATH (i.e. the user's go path).
GOPATH := $(shell env PATH=$(PATH) go env GOPATH)
# Add $GOPATH/bin to path
PATH := $(GOPATH)/bin:$(PATH)
# extract git hash
BUILD_GIT_HASH := $(shell git rev-parse HEAD 2>/dev/null || echo "0")
GIT_TAG := $(shell git describe --tags 2>/dev/null || echo "v0.0.0")
BUILD_VERSION := $(shell echo ${GIT_TAG} | grep -P -o '(?<=v)[0-9]+.[0-9]+.[0-9]')
# default golang flags
LD_FLAGS := '-X main.buildVersion=$(BUILD_VERSION) -X main.buildGitHash=$(BUILD_GIT_HASH)'
# directory of Makefile
MAKEFILE_DIR = $(shell pwd)
GO_FILES := $(wildcard ./pkg/places/*.go ./internal/*.go ./*.go)
all: berlinplaces
data: _data/extractCSV.sql _data/extractCSV.sh
cd _data && ./extractCSV.sh
fmt:
go fmt .
go fmt github.com/heimdalr/berlinplaces/pkg/...
test:
go test -p 4 -v ./...
lint:
golangci-lint run
coverage:
go test -coverprofile=c.out github.com/heimdalr/berlinplaces/pkg/... && go tool cover -html=c.out
berlinplaces: $(GO_FILES)
go build \
-ldflags $(LD_FLAGS) \
-o $@ \
.
run_berlinplaces: berlinplaces
./berlinplaces
build_image: Dockerfile
docker build -t berlinplaces .
run_image: stop_image
docker run -p 8080:8080 -e PLACES_DEBUG=true --name berlinplaces berlinplaces
stop_image:
docker stop berlinplaces 2>/dev/null || true
docker rm berlinplaces 2>/dev/null || true
# ask for a version / tag to set and then update openapi.yaml, tag and push the tag
release:
@read -p "tag (current: \"${BUILD_VERSION}\"): " tag && \
sed -i "/info/,/tags/ s/[0-9]\+\.[0-9]\+\.[0-9]\+/$$tag/" swagger/openapi.yaml && \
git add swagger/openapi.yaml && \
git commit -m "bumped version to v$$tag" && \
git tag -a "v$$tag" -m "v$$tag"
start_nominatim:
docker run --rm -d --shm-size=8g \
-e PBF_URL=https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf \
-e REPLICATION_URL=https://download.geofabrik.de/europe/germany/berlin-updates/ \
-e IMPORT_WIKIPEDIA=false \
-e FREEZE=true \
-v $(MAKEFILE_DIR)/_data/nominatim/.nominatim-data:/var/lib/postgresql/12/main \
-p 8081:8080 \
-p 5432:5432 \
--name nominatim \
mediagis/nominatim:4.0
stop_nominatim:
docker stop nominatim 2>/dev/null || true
clean:
rm -f berlinplaces c.out
.PHONY: all data fmt test lint coverage run_berlinplaces build_image run_image stop_image start_nominatim stop_nominatim clean