-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
77 lines (62 loc) · 2.1 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
##
# Makefile for the Lurch Slack bot.
#
# Targets:
# - docker create a docker image containing Lurch.
# - clean delete all generated files.
# - run run the service.
# - build compile executable.
#
# Meta targets:
# - all is the default target; it builds the lurch binary.
#
# Golang source files.
SRC_FILES := $(shell ls *.go)
# Build dependencies.
BUILD_DEPS := vendor $(SRC_FILES)
# Create production Docker image components by default.
all: build
# Create a docker image for use in production environments. This first builds
# the development docker image, then copies the lurch binary from this image to
# the current working directory, from where it builds the production image.
docker:
docker run --rm -v $$(pwd):/tmp/lurch $$(docker build --quiet --file docker/Dockerfile .) cp lurch cacert.pem /tmp/lurch && \
docker build -t geodata/lurch:latest .
# Create a development environment.
dev:
docker-compose build --force-rm lurch && \
docker-compose run lurch bash
# Create components required for the production Docker image.
build: lurch cacert.pem
# Run the tests.
test:
drone exec
# Remove automatically generated files.
clean:
@rm -f lurch
@rm -rf vendor
@rm -f cacert.pem
# Run the service.
run: realize.config.yaml vendor
realize run
# Build an executable optimised for a linux container environment. See
# <https://medium.com/@kelseyhightower/optimizing-docker-images-for-static-binaries-b5696e26eb07#.otbjvqo3i>.
lurch: LURCH_VERSION := $(shell git describe --tags --abbrev=0 --match 'v[0-9]*')
lurch: LURCH_COMMIT := $(shell git rev-parse --short HEAD)
lurch: $(BUILD_DEPS)
CGO_ENABLED=0 \
GOOS=linux \
go build -a -tags netgo -ldflags '-w -X main.version=$(LURCH_VERSION) -X main.commit=$(LURCH_COMMIT)' -o lurch
vendor: glide.yaml glide.lock
glide install && \
touch -c vendor
glide.lock:
glide update && \
touch -c vendor
glide.yaml:
glide init
# Get the PEM root certificates for use in the production docker image.
cacert.pem:
curl --silent --location https://curl.haxx.se/ca/cacert.pem > cacert.pem
# Targets without filesystem equivalents.
.PHONY: all build clean run dev docker