blob: 11e9f1dd6167cfc31f4f5c6fa09aa0b62dc7d106 [file] [log] [blame]
Hyunsun Moon3386a852019-07-26 14:56:11 -06001#
2# Copyright 2019-present Open Networking Foundation
3#
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
17VERSION ?= $(shell cat ./VERSION)
18ENB_NAME ?= lte-softmodem
19UE_NAME ?= lte-uesoftmodem
20
21DOCKER_TAG ?= ${VERSION}
22DOCKER_REGISTRY ?=
23DOCKER_REPOSITORY ?=
24DOCKER_BUILD_ARGS ?=
25ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG}
26UE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${UE_NAME}:${DOCKER_TAG}
27
28## Docker labels. Only set ref and commit date if committed
29DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
30DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
31DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
32DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
33
34# https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target
35docker-build:
36 docker build $(DOCKER_BUILD_ARGS) \
37 --target ${ENB_NAME} \
38 --tag ${ENB_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 .
45 docker build $(DOCKER_BUILD_ARGS) \
46 --target ${UE_NAME} \
47 --tag ${UE_IMAGENAME} \
48 --build-arg org_label_schema_version="${VERSION}" \
49 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
50 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
51 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
52 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
53 .
54
55docker-push:
56 docker push ${ENB_IMAGENAME}
57 docker push ${UE_IMAGENAME}
58
59test: docker-build
60
61.PHONY: docker-build docker-push test