blob: e030c9d4cffda36d74df9640607d3808845e408c [file] [log] [blame]
Bin Luf1b0f472018-08-22 11:33:38 +08001###############################################################################
2# Shortcut targets
3default: image
4all: image
5
6EMPTY :=
7SPACE := $(EMPTY) $(EMPTY)
8COMMA := $(EMPTY),$(EMPTY)
9
10LINUX_ARCH := amd64 arm64
11PLATFORMS := $(subst $(SPACE),$(COMMA),$(foreach arch,$(LINUX_ARCH),linux/$(arch)))
12
13REGISTRY ?= nexus3.onap.org:10001/onap/vnfsdk/refrepo
14VERSION := latest
15TARGET := vnfsdk
16DOCKERFILE := Dockerfile
17
18DOCKERFILE_PATH := ./
19POSTGRES_PATH := "vnfmarket-be/deployment/docker/docker-postgres/src/main/docker"
20REFREPO_PATH := "vnfmarket-be/deployment/docker/docker-refrepo/src/main/docker"
21
22MANIFEST_TOOL_DIR := /usr/local/bin
23MANIFEST_TOOL_VERSION := v0.7.0
24
25clean:
26 rm -f ${POSTGRES_PATH}/Dockerfile-*
27 rm -f ${REFREPO_PATH}/Dockerfile-*
28 rm -f $(MANIFEST_TOOL_DIR)/manifest-tool
29
30pre:
31 for arch in $(LINUX_ARCH); do \
32 if [ $$arch = arm64 ]; then \
33 sed -e '/FROM ubuntu:16.04/r Dockerfile_header_arm64' ${POSTGRES_PATH}/Dockerfile > ${POSTGRES_PATH}/Dockerfile-$$arch; \
34 sed -i 's/FROM ubuntu:16.04//g' ${POSTGRES_PATH}/Dockerfile-$$arch; \
35 sed -e 's/postgres:/arm64v8\/postgres:/g' ${REFREPO_PATH}/Dockerfile > ${REFREPO_PATH}/Dockerfile-$$arch; \
36 else \
37 echo ""; \
38 fi \
39 done
40
41pre_manifest:
42 curl -sSL https://github.com/estesp/manifest-tool/releases/download/$(MANIFEST_TOOL_VERSION)/manifest-tool-linux-amd64 > $(MANIFEST_TOOL_DIR)/manifest-tool
43 chmod +x $(MANIFEST_TOOL_DIR)/manifest-tool
44
45###############################################################################
46# Building docker images
47###############################################################################
48build_image:
49 docker build -t $(REGISTRY)/$(TARGET):$(VERSION) -f $(DOCKERFILE) $(DOCKERFILE_PATH)
50image: pre
51 for arch in $(LINUX_ARCH); do \
52 if [ $$arch = amd64 ]; then \
53 $(MAKE) build_image TARGET="postgres-$$arch" DOCKERFILE=${POSTGRES_PATH}/Dockerfile DOCKERFILE_PATH=$(POSTGRES_PATH); \
54 $(MAKE) build_image TARGET="refrepo-$$arch" DOCKERFILE=${REFREPO_PATH}/Dockerfile DOCKERFILE_PATH=$(REFREPO_PATH); \
55 elif [ $$arch = arm64 ]; then \
56 $(MAKE) build_image TARGET="postgres-$$arch" DOCKERFILE=${POSTGRES_PATH}/Dockerfile-$$arch DOCKERFILE_PATH=$(POSTGRES_PATH); \
57 $(MAKE) build_image TARGET="refrepo-$$arch" DOCKERFILE=${REFREPO_PATH}/Dockerfile-$$arch DOCKERFILE_PATH=$(REFREPO_PATH); \
58 else \
59 echo "ARCH unknown"; \
60 fi \
61 done
62
63###############################################################################
64# push images, please use command: make push
65###############################################################################
66push-manifest:
67 $(MANIFEST_TOOL_DIR)/manifest-tool push from-args --platforms $(PLATFORMS) --template $(REGISTRY)/$(TARGET)-ARCH:$(VERSION) --target $(REGISTRY)/$(TARGET):$(VERSION)
68
69push-single-image:
70 docker push $(REGISTRY)/$(TARGET):$(VERSION)
71
72push: pre_manifest
73 for arch in $(LINUX_ARCH); do \
74 $(MAKE) push-single-image TARGET="postgres-$$arch"; \
75 $(MAKE) push-single-image TARGET="refrepo-$$arch"; \
76 done
77 $(MAKE) push-manifest TARGET="postgres"
78 $(MAKE) push-manifest TARGET="refrepo"