This repository has been archived by the owner on Mar 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker.version.mk
167 lines (120 loc) · 3.97 KB
/
docker.version.mk
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
### BASE_IMAGE #################################################################
BASE_IMAGE_NAME ?= $(DOCKER_PROJECT)/openjdk
BASE_IMAGE_TAG ?= 8u151-jre-centos
### DOCKER_IMAGE ###############################################################
ELASTICSEARCH_TAG ?= $(ELASTICSEARCH_VERSION)
DOCKER_PROJECT ?= sicz
DOCKER_PROJECT_DESC ?= A NoSQL database and search engine
DOCKER_PROJECT_URL ?= https://www.elastic.co/products/elasticsearch
DOCKER_NAME ?= elasticsearch
DOCKER_IMAGE_TAG ?= $(ELASTICSEARCH_TAG)
### BUILD ######################################################################
# Docker image build variables
BUILD_VARS += ELASTICSEARCH_VERSION \
ELASTICSEARCH_TAG
### EXECUTOR ###################################################################
# Use the Docker Compose executor
DOCKER_EXECUTOR ?= compose
# Variables used in the Docker Compose file
COMPOSE_VARS += ELASTICSEARCH_URL \
SERVER_CRT_HOST \
SIMPLE_CA_IMAGE
# Certificate subject aletrnative names
SERVER_CRT_HOST += $(SERVICE_NAME).local
# Elasticsearch HTTP endpoint
ELASTICSEARCH_URL ?= http://elasticsearch.local:9200
### SIMPLE_CA ##################################################################
# Docker image dependencies
DOCKER_IMAGE_DEPENDENCIES += $(SIMPLE_CA_IMAGE)
# Simple CA image
SIMPLE_CA_IMAGE_NAME ?= $(DOCKER_PROJECT)/simple-ca
SIMPLE_CA_IMAGE_TAG ?= latest
SIMPLE_CA_IMAGE ?= $(SIMPLE_CA_IMAGE_NAME):$(SIMPLE_CA_IMAGE_TAG)
### MAKE_VARS ##################################################################
# Display the make variables
MAKE_VARS ?= GITHUB_MAKE_VARS \
CONFIG_MAKE_VARS \
BASE_IMAGE_MAKE_VARS \
DOCKER_IMAGE_MAKE_VARS \
BUILD_MAKE_VARS \
EXECUTOR_MAKE_VARS \
SHELL_MAKE_VARS \
DOCKER_REGISTRY_MAKE_VARS
define CONFIG_MAKE_VARS
ELASTICSEARCH_VERSION: $(ELASTICSEARCH_VERSION)
ELASTICSEARCH_TAG: $(ELASTICSEARCH_TAG)
SIMPLE_CA_IMAGE_NAME: $(SIMPLE_CA_IMAGE_NAME)
SIMPLE_CA_IMAGE_TAG: $(SIMPLE_CA_IMAGE_TAG)
SIMPLE_CA_IMAGE: $(SIMPLE_CA_IMAGE)
SERVER_CRT_HOST: $(SERVER_CRT_HOST)
endef
export CONFIG_MAKE_VARS
### MAKE_TARGETS ###############################################################
# Build a new image and run the tests
.PHONY: all
all: clean build start wait logs test
# Build a new image and run the tests
.PHONY: ci
ci: all
@$(MAKE) clean
### BUILD_TARGETS ##############################################################
# Build a new image with using the Docker layer caching
.PHONY: build
build: docker-build
# Build a new image without using the Docker layer caching
.PHONY: rebuild
rebuild: docker-rebuild
### EXECUTOR_TARGETS ###########################################################
# Display the configuration file
.PHONY: config-file
config-file: display-config-file
# Display the make variables
.PHONY: vars
vars: display-makevars
# Remove the containers and then run them fresh
.PHONY: run up
run up: docker-up
# Create the containers
.PHONY: create
create: docker-create
# Start the containers
.PHONY: start
start: create docker-start
# Wait for the start of the containers
.PHONY: wait
wait: start docker-wait
# Display running containers
.PHONY: ps
ps: docker-ps
# Display the container logs
.PHONY: logs
logs: docker-logs
# Follow the container logs
.PHONY: logs-tail tail
logs-tail tail: docker-logs-tail
# Run shell in the container
.PHONY: shell sh
shell sh: start docker-shell
# Run the tests
.PHONY: test
test: start docker-test
# Run the shell in the test container
.PHONY: test-shell tsh
test-shell tsh:
@$(MAKE) test TEST_CMD=/bin/bash
# Stop the containers
.PHONY: stop
stop: docker-stop
# Restart the containers
.PHONY: restart
restart: stop start
# Remove the containers
.PHONY: down rm
down rm: docker-rm
# Remove all containers and work files
.PHONY: clean
clean: docker-clean
### MK_DOCKER_IMAGE ############################################################
MK_DIR ?= $(PROJECT_DIR)/../Mk
include $(MK_DIR)/docker.image.mk
################################################################################