This repository has been archived by the owner on Aug 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (56 loc) · 2.24 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
#===============================================================================
# Default User Options
#===============================================================================
# Build-time arguments
GCC_VERSION ?= 9.2.0
OMPI_VERSION ?= 4.0.0
# Spack variants
EXTRA_SPECS ?= "target=skylake"
OMPI_OPTIONS ?= ""
# Image name
DOCKER_IMAGE ?= leavesask/gompi
DOCKER_TAG := $(OMPI_VERSION)
#===============================================================================
# Variables and objects
#===============================================================================
# Append a suffix to the tag if the version number of GCC
# is specified
DOCKER_TAG_FULL := $(DOCKER_TAG)
ifneq ($(GCC_VERSION),latest)
DOCKER_TAG_FULL := $(DOCKER_TAG)-gcc-$(GCC_VERSION)
endif
BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
VCS_URL=$(shell git config --get remote.origin.url)
# Get the latest commit
GIT_COMMIT = $(strip $(shell git rev-parse --short HEAD))
#===============================================================================
# Targets to Build
#===============================================================================
.PHONY : docker_build docker_push output
default: build
build: docker_build output
release: docker_build docker_push output
docker_build:
# Build Docker image
docker build \
--build-arg GCC_VERSION=$(GCC_VERSION) \
--build-arg OMPI_VERSION=$(OMPI_VERSION) \
--build-arg OMPI_OPTIONS=$(OMPI_OPTIONS) \
--build-arg EXTRA_SPECS=$(EXTRA_SPECS) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
--build-arg VCS_URL=$(VCS_URL) \
--build-arg VCS_REF=$(GIT_COMMIT) \
-t $(DOCKER_IMAGE):$(DOCKER_TAG) .
docker_push:
# Tag image as latest
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):latest
# Push to DockerHub
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
docker push $(DOCKER_IMAGE):latest
# Tag image with the full tag
if [[ "$(DOCKER_TAG)" != "$(DOCKER_TAG_FULL)" ]]; then \
docker tag $(DOCKER_IMAGE):$(DOCKER_TAG) $(DOCKER_IMAGE):$(DOCKER_TAG_FULL) && \
docker push $(DOCKER_IMAGE):$(DOCKER_TAG_FULL); \
fi
output:
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)