forked from Gerrrr/elasticsearch-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (53 loc) · 2.01 KB
/
Makefile
File metadata and controls
70 lines (53 loc) · 2.01 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
SHELL=/bin/bash
export PATH := ./bin:./venv/bin:$(PATH)
ifndef ELASTIC_VERSION
ELASTIC_VERSION := $(shell cat version.txt)
endif
ifdef STAGING_BUILD_NUM
VERSION_TAG := $(ELASTIC_VERSION)-$(STAGING_BUILD_NUM)
else
VERSION_TAG := $(ELASTIC_VERSION)
endif
ELASTIC_REGISTRY := docker.elastic.co
VERSIONED_IMAGE := $(ELASTIC_REGISTRY)/elasticsearch/elasticsearch:$(VERSION_TAG)
# When invoking docker-compose, use an extra config fragment to map Elasticsearch's
# listening port to the docker host.
DOCKER_COMPOSE := docker-compose -f docker-compose.yml -f docker-compose.hostports.yml
.PHONY: test clean pristine run run-single run-cluster build push
# Default target, build *and* run tests
test: lint build docker-compose.yml
./bin/testinfra tests
./bin/testinfra --single-node tests
lint: venv
flake8 tests
clean:
@if [ -f "docker-compose.yml" ]; then docker-compose down -v && docker-compose rm -f -v; fi
rm -f docker-compose.yml build/elasticsearch/Dockerfile
pristine: clean
docker rmi -f $(VERSIONED_IMAGE)
run: run-single
run-single: build docker-compose.yml
$(DOCKER_COMPOSE) up elasticsearch1
run-cluster: build docker-compose.yml
$(DOCKER_COMPOSE) up elasticsearch1 elasticsearch2
# Build docker image: "elasticsearch:$(VERSION_TAG)"
build: clean dockerfile
docker build -t $(VERSIONED_IMAGE) build/elasticsearch
push: test
docker push $(VERSIONED_IMAGE)
# The tests are written in Python. Make a virtualenv to handle the dependencies.
venv: requirements.txt
test -d venv || virtualenv --python=python3.5 venv
pip install -r requirements.txt
touch venv
# Generate the Dockerfile from a Jinja2 template.
dockerfile: venv templates/Dockerfile.j2
jinja2 \
-D elastic_version='$(ELASTIC_VERSION)' \
-D staging_build_num='$(STAGING_BUILD_NUM)' \
templates/Dockerfile.j2 > build/elasticsearch/Dockerfile
# Generate the docker-compose.yml from a Jinja2 template.
docker-compose.yml: venv templates/docker-compose.yml.j2
jinja2 \
-D version_tag='$(VERSION_TAG)' \
templates/docker-compose.yml.j2 > docker-compose.yml