Zack Williams | f173e4f | 2019-08-30 17:15:24 -0700 | [diff] [blame] | 1 | # Copyright 2019-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Andy Bavier | 25ebf0e | 2017-06-06 18:27:15 -0400 | [diff] [blame] | 14 | |
Zack Williams | f173e4f | 2019-08-30 17:15:24 -0700 | [diff] [blame] | 15 | # Configure shell |
| 16 | SHELL = bash -e -o pipefail |
Andy Bavier | 1fd3917 | 2017-07-20 15:54:11 -0700 | [diff] [blame] | 17 | |
Zack Williams | f173e4f | 2019-08-30 17:15:24 -0700 | [diff] [blame] | 18 | ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 19 | |
| 20 | VERSION ?= $(shell cat ./VERSION) |
| 21 | |
| 22 | DOCKER_REGISTRY ?= |
| 23 | DOCKER_REPOSITORY ?= |
| 24 | DOCKER_BUILD_ARGS ?= |
| 25 | DOCKER_TAG ?= ${VERSION} |
| 26 | DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}mavenrepo:${DOCKER_TAG} |
| 27 | |
| 28 | ## Docker labels. Only set ref and commit date if committed |
| 29 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 30 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 31 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 32 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
Andy Bavier | 25ebf0e | 2017-06-06 18:27:15 -0400 | [diff] [blame] | 33 | |
| 34 | .PHONY: all |
Zack Williams | f173e4f | 2019-08-30 17:15:24 -0700 | [diff] [blame] | 35 | all: docker-build |
Andy Bavier | 25ebf0e | 2017-06-06 18:27:15 -0400 | [diff] [blame] | 36 | |
Zack Williams | f173e4f | 2019-08-30 17:15:24 -0700 | [diff] [blame] | 37 | docker-build: |
| 38 | docker build $(DOCKER_BUILD_ARGS) \ |
| 39 | -t ${DOCKER_IMAGENAME} \ |
| 40 | --build-arg org_label_schema_version="${VERSION}" \ |
| 41 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 42 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 43 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 44 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 45 | -f Dockerfile.make ${ROOT_DIR} |
| 46 | |
| 47 | docker-push: |
| 48 | docker push ${DOCKER_IMAGENAME} |
Andy Bavier | 1fd3917 | 2017-07-20 15:54:11 -0700 | [diff] [blame] | 49 | |
David K. Bainbridge | 56da957 | 2017-08-17 09:56:50 -0700 | [diff] [blame] | 50 | .PHONY: onos |
| 51 | onos: |
| 52 | docker build -t cord/onos:latest -f docker/Dockerfile.onos . |
| 53 | |
Andy Bavier | 25ebf0e | 2017-06-06 18:27:15 -0400 | [diff] [blame] | 54 | .PHONY: test |
| 55 | test: |
| 56 | @echo "No unit tests at present" |
| 57 | |
| 58 | .PHONY: help |
| 59 | help: |
| 60 | @echo "Available targets:" |
Andy Bavier | 1fd3917 | 2017-07-20 15:54:11 -0700 | [diff] [blame] | 61 | @echo " build: build the Docker image (Maven repo with the CORD ONOS apps)" |
Andy Bavier | 25ebf0e | 2017-06-06 18:27:15 -0400 | [diff] [blame] | 62 | @echo " clean: remove the Docker image" |
| 63 | @echo " test: run unit tests" |
| 64 | @echo " help: print this help message" |
| 65 | |