forked from giovtorres/slurm-docker-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (51 loc) · 1.82 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
# default build target
all::
all:: pre build
.PHONY: all test
MAINTAINER:="Harvard IQSS <[email protected]>"
MAINTAINER_URL:="https://github.com/hmdc/slurm-docker-cluster"
IMAGE_NAME:=hmdc/slurm-docker-cluster
GIT_SHA:=$(shell git rev-parse HEAD)
OS:=$(shell uname | tr '[:upper:]' '[:lower:]')
GIT_BRANCH:=$(shell git rev-parse --abbrev-ref HEAD)
CONTAINER_TEST_VERSION:=1.8.0
export PATH:=$(PWD)/test/test_helper/bats-core/bin:$(PATH)
# Check Make version (we need at least GNU Make 3.82). Fortunately,
# 'undefine' directive has been introduced exactly in GNU Make 3.82.
ifeq ($(filter undefine,$(value .FEATURES)),)
$(error Unsupported Make version. \
The build system does not work properly with GNU Make $(MAKE_VERSION), \
please use GNU Make 3.82 or above.)
endif
ifeq ($(GIT_BRANCH), master)
IMAGE_TAG:=$(IMAGE_NAME):$(SLURM_TAG)-$(GIT_SHA)
PREFIX:=$(SLURM_TAG)
else
IMAGE_TAG:=$(IMAGE_NAME):$(SLURM_TAG)-$(GIT_BRANCH)-$(GIT_SHA)
PREFIX:=$(SLURM_TAG)-$(GIT_BRANCH)
endif
GIT_DATE:="$(shell TZ=UTC git show --quiet --date='format-local:%Y-%m-%d %H:%M:%S +0000' --format='%cd')"
BUILD_DATE:="$(shell date -u '+%Y-%m-%d %H:%M:%S %z')"
build:
# "base" image
docker build \
--pull \
--build-arg SLURM_TAG=$(SLURM_TAG) \
--build-arg MAINTAINER=$(MAINTAINER) \
--build-arg MAINTAINER_URL=$(MAINTAINER_URL) \
--build-arg GIT_SHA="$(GIT_SHA)" \
--build-arg GIT_DATE=$(GIT_DATE) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--tag $(IMAGE_TAG) \
--tag $(IMAGE_NAME):$(PREFIX) \
--file Dockerfile .
push:
docker login -u $(DOCKERHUB_USERNAME) -p "$(DOCKERHUB_TOKEN)"
docker push $(IMAGE_NAME):$(PREFIX)
docker tag $(IMAGE_NAME):$(PREFIX) $(IMAGE_TAG)
docker push $(IMAGE_TAG)
test:
docker-compose up -d
mkdir -p ./test-results
bats --report-formatter junit ./test/test.bats -o ./test-results
docker-compose down -v