This repository was archived by the owner on Oct 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (43 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
#===============================================================================
# Default User Options
#===============================================================================
# Build-time arguments
LLVM_VERSION ?= 9.0.1
# Spack variants
EXTRA_SPECS ?= "target=skylake"
LLVM_OPTIONS ?= ""
# Image name
DOCKER_IMAGE ?= leavesask/llvm
DOCKER_TAG := $(LLVM_VERSION)
#===============================================================================
# Variables and objects
#===============================================================================
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 LLVM_VERSION=$(LLVM_VERSION) \
--build-arg LLVM_OPTIONS=$(LLVM_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
output:
@echo Docker Image: $(DOCKER_IMAGE):$(DOCKER_TAG)