bluval engine refactoring
[validation.git] / docker / build.mk
1 ##############################################################################
2 # Copyright (c) 2019 AT&T, ENEA AB, Nokia and others                         #
3 #                                                                            #
4 # Licensed under the Apache License, Version 2.0 (the "License");            #
5 # you maynot use this file except in compliance with the License.            #
6 #                                                                            #
7 # You may obtain a copy of the License at                                    #
8 #       http://www.apache.org/licenses/LICENSE-2.0                           #
9 #                                                                            #
10 # Unless required by applicable law or agreed to in writing, software        #
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
13 # See the License for the specific language governing permissions and        #
14 # limitations under the License.                                             #
15 ##############################################################################
16
17
18 # declare the variables
19 REGISTRY ?= akraino
20 NAME ?= validation
21 TAG_PRE ?= $(notdir $(CURDIR))
22 TAG_VER ?= latest
23 DOCKERFILE ?= Dockerfile
24 MTOOL ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST))))/manifest-tool
25
26 # get the architecture of the host
27 HOST_ARCH = amd64
28 ifeq ($(shell uname -m), aarch64)
29     HOST_ARCH = arm64
30 endif
31
32 $(MTOOL):
33         wget https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-$(HOST_ARCH) -O $@
34         sudo chmod +x $@
35
36 .PHONY: .build
37 .build:
38         docker build \
39                 -t $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER) \
40                 -f $(DOCKERFILE) \
41                 .
42
43 .PHONY: .push_image
44 .push_image: .build
45         docker push $(REGISTRY)/$(NAME):$(TAG_PRE)-$(HOST_ARCH)-$(TAG_VER)
46
47 .PHONY: .push_manifest
48 .push_manifest: $(MTOOL)
49         $(MTOOL) push from-args \
50                 --platforms linux/amd64,linux/arm64 \
51                 --template $(REGISTRY)/$(NAME):$(TAG_PRE)-ARCH-$(TAG_VER) \
52                 --target $(REGISTRY)/$(NAME):$(TAG_PRE)-$(TAG_VER)