blob: c6607cc089adbc369a871ff85eb125b6e359b320 [file] [log] [blame]
Scott Bakerbdb962b2020-04-03 10:53:36 -07001# Copyright 2018-present Open Networking Foundation
Dinesh Belwalkar6c0bc752020-04-24 23:47:53 +00002# Copyright 2018-present Edgecore Networks Corporation
Scott Bakerbdb962b2020-04-03 10:53:36 -07003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
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,
12# WITHOUT 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# Configure shell
17SHELL = bash -eu -o pipefail
18
19# Variables
20VERSION ?= $(shell cat ../VERSION)
21CONTAINER_NAME ?= redfish-mockup-server
22
23## Docker related
24DOCKER_REGISTRY ?=
25DOCKER_REPOSITORY ?=
26DOCKER_BUILD_ARGS ?=
27DOCKER_TAG ?= ${VERSION}
28DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
29
30## Docker labels. Only set ref and commit date if committed
31DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
32DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
33DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
34DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
35
36docker-build:
37 docker build $(DOCKER_BUILD_ARGS) \
38 -t ${DOCKER_IMAGENAME} \
39 --build-arg org_label_schema_version="${VERSION}" \
40 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
41 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
42 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
43 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
44 -f Dockerfile .
45
46docker-push:
47 docker push ${DOCKER_IMAGENAME}