-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (56 loc) · 1.92 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
##
# Makefile for the Open Groupware iCalendar service.
#
# Targets:
# - docker create a docker image containing Ogo-Ical.
# - clean delete all generated files.
# - run run the service.
# - dev enter a development environment.
#
# Meta targets:
# - all is the default target; it builds the ogo-ical binary.
#
# Golang source files.
SRC_FILES := $(shell ls *.go)
# Build dependencies.
BUILD_DEPS := vendor $(SRC_FILES)
# Create production Docker image components by default.
all: ogo-ical
# Create a docker image for use in production environments. This first builds
# the development docker image, then copies the ogo-ical binary from this image to
# the current working directory, from where it builds the production image.
docker:
docker run --rm -v $$(pwd):/tmp/ogo-ical $$(docker build --quiet --file docker/Dockerfile .) cp ogo-ical /tmp/ogo-ical && \
docker build -t geodata/ogo-ical:latest .
# Enter the development environment.
dev:
docker-compose rm -f -v dev && \
docker-compose run --rm --service-ports dev
# Run the tests.
test:
go test
# Remove automatically generated files.
clean:
@rm -f ogo-ical
@rm -rf vendor
# 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>.
ogo-ical: OGOICAL_VERSION := $(or $(shell git describe --tags --abbrev=0 --match 'v[0-9]*'), dev)
ogo-ical: OGOICAL_COMMIT := $(or $(shell git rev-parse --short HEAD), unknown)
ogo-ical: $(BUILD_DEPS)
CGO_ENABLED=0 \
GOOS=linux \
go build -a -tags netgo -ldflags '-w -X main.version=$(OGOICAL_VERSION) -X main.commit=$(OGOICAL_COMMIT)' -o ogo-ical
vendor: glide.yaml glide.lock
glide install && \
touch -c vendor
glide.lock:
glide update && \
touch -c vendor
glide.yaml:
glide init
# Targets without filesystem equivalents.
.PHONY: all clean run dev docker