forked from mheese/journalbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (79 loc) · 2.17 KB
/
Copy pathMakefile
File metadata and controls
93 lines (79 loc) · 2.17 KB
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
# Journalbeats Makefile
#
# This Makefile contains a collection of targets to help with docker image
# maintenance and creation. Run `make docker-build` to build the docker
# image. Run `make docker-tag` to build the image and tag the docker image
# with the current git tag. Run `make docker-push` to push all tags to docker hub.
#
# Note: This Makefile can be modified to include any future non-docker build
# tasks as well.
IMAGE_NAME := mheese/journalbeat
IMAGE_BUILD_NAME := mheese-journalbeat-build
GIT_BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD | sed "sX/X-Xg")
GIT_TAG_NAME := $(shell git describe --tags)
TAGS := $(GIT_BRANCH_NAME) $(GIT_TAG_NAME)
ifeq ($(GIT_BRANCH_NAME),master)
TAGS += latest
endif
TAGS := $(foreach t,$(TAGS),$(IMAGE_NAME):$(t))
#
# Clean up the project
#
clean:
rm -f Dockerfile
rm -rf build
.PHONY: clean
#
# Copy the Dockerfile for the build to the main project directory
#
Dockerfile:
cp docker/dockerfile.build Dockerfile
#
# Make the build directory
#
build: Dockerfile build/journalbeat
#
# Build the journalbeat go image using docker
#
build/journalbeat:
mkdir -p build
docker build -t $(IMAGE_BUILD_NAME) .
docker run --name $(IMAGE_BUILD_NAME) $(IMAGE_BUILD_NAME)
-docker cp $(IMAGE_BUILD_NAME):/go/src/github.com/mheese/journalbeat/journalbeat build/journalbeat
docker rm $(IMAGE_BUILD_NAME)
docker rmi $(IMAGE_BUILD_NAME)
#
# Copy the Dockerfile for release to the build directory
#
build/Dockerfile:
cp docker/dockerfile.release build/Dockerfile
#
# Copy the default journalbeat.yml for release to the build directory
#
build/journalbeat.yml:
cp docker/journalbeat.yml build/journalbeat.yml
#
# docker tag the image
#
docker-tag: docker-build
echo $(TAGS) | xargs -n 1 docker tag $(IMAGE_NAME)
.PHONY: docker-tag
#
# docker build the image
#
docker-build: build build/Dockerfile build/journalbeat.yml
cd build && docker build -t $(IMAGE_NAME) .
.PHONY: docker-build
#
# docker push all tags
#
docker-push: docker-tag
echo $(TAGS) | xargs -n 1 docker push
.PHONY: docker-push
#
# show the current version and branch name, for quick reference.
#
version:
@echo Version: $(GIT_TAG_NAME)
@echo Branch: $(GIT_BRANCH_NAME)
.PHONY: version