-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
77 lines (60 loc) · 1.73 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
# test cmd
TEST_CMD := -f /app/wms-load-test/locustfile.py
# META
DOCKER_REPO := eduardrosert/locust-wms-test
SOURCE_COMMIT := $(shell git rev-parse HEAD)
GIT_TAG := $(shell git describe --tags --abbrev=0)
# Find out if the working directory is clean
GIT_NOT_CLEAN_CHECK := $(shell git status --porcelain)
ifneq (x${GIT_NOT_CLEAN_CHECK}, x)
DOCKER_TAG_SUFFIX = -dirty
endif
GIT_URL := $(shell git config --get remote.origin.url)
LATEST := ${DOCKER_REPO}:latest
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# If this is not a tagged version
# replace docker tag with 'latest'
ifeq ('${GIT_TAG}','')
DOCKER_TAG = latest
else
DOCKER_TAG = version-$(GIT_TAG)
endif
IMAGE_NAME = ${DOCKER_REPO}:${DOCKER_TAG}${DOCKER_TAG_SUFFIX}
# If this git repo has no remote
# url, set it to <unknown>
ifeq ('${GIT_URL}','')
GIT_URL = <unknown>
endif
all: build
.PHONY: build run run-interactive test login login-user-pass push clean
build:
@echo "Building ${IMAGE_NAME} ..."
docker build \
--build-arg BUILD_DATE=${DATE} \
--build-arg VCS_URL=${GIT_URL} \
--build-arg VCS_REF=${SOURCE_COMMIT} \
--build-arg VERSION=${DOCKER_TAG} \
--build-arg http_proxy=${http_proxy} \
--build-arg https_proxy=${https_proxy} \
--build-arg ftp_proxy=${ftp_proxy} \
--build-arg no_proxy="${no_proxy}" \
--file Dockerfile \
--tag ${IMAGE_NAME} \
.
@docker tag ${IMAGE_NAME} ${LATEST}
run:
@docker run --rm -i -t ${IMAGE_NAME}
run-interactive:
@docker run --rm -i -t ${IMAGE_NAME} sh
run-k8s:
@kubectl apply -f k8s-locust-wms-test.yaml
test:
@docker run --rm -i -t ${IMAGE_NAME} ${TEST_CMD}
login:
@docker login
login-user-pass:
@docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
push: login
@docker push ${DOCKER_REPO}
clean:
@docker rmi ${DOCKER_REPO}