blob: cdb20520ce38c8a778f021676903f2b8ff6b59e7 [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)
Hyunsun Moon9e87a152019-07-27 04:47:46 -060018BASE_NAME ?= oai-base
Hyunsun Moon3386a852019-07-26 14:56:11 -060019UE_NAME ?= lte-uesoftmodem
Hyunsun Moon9e87a152019-07-27 04:47:46 -060020ENB_NAME ?= lte-softmodem
Hyunsun Moon3386a852019-07-26 14:56:11 -060021
Hyunsun Moon9e87a152019-07-27 04:47:46 -060022# Tag is fixed to OAI release version, v1.0.0, regardless of VERSION file
Hyunsun423c2cb2020-10-28 01:54:41 -050023DOCKER_TAG ?= 1.1.0
Hyunsun Moon3386a852019-07-26 14:56:11 -060024DOCKER_REGISTRY ?=
25DOCKER_REPOSITORY ?=
26DOCKER_BUILD_ARGS ?=
Hyunsun Moon9e87a152019-07-27 04:47:46 -060027BASE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${BASE_NAME}:${DOCKER_TAG}
Hyunsun Moon3386a852019-07-26 14:56:11 -060028UE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${UE_NAME}:${DOCKER_TAG}
Hyunsun Moon9e87a152019-07-27 04:47:46 -060029ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG}
Hyunsun Moon3386a852019-07-26 14:56:11 -060030
31## Docker labels. Only set ref and commit date if committed
32DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
33DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
34DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
35DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
36
37# https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target
38docker-build:
39 docker build $(DOCKER_BUILD_ARGS) \
Hyunsun Moon9e87a152019-07-27 04:47:46 -060040 --target ${BASE_NAME} \
41 --tag ${BASE_IMAGENAME} \
42 --file Dockerfile.base \
Hyunsun Moon3386a852019-07-26 14:56:11 -060043 --build-arg org_label_schema_version="${VERSION}" \
44 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
45 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
46 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
47 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
48 .
49 docker build $(DOCKER_BUILD_ARGS) \
50 --target ${UE_NAME} \
51 --tag ${UE_IMAGENAME} \
Hyunsun Moon9e87a152019-07-27 04:47:46 -060052 --file Dockerfile.ue \
53 --build-arg build_base=${BASE_IMAGENAME} \
54 --build-arg org_label_schema_version="${VERSION}" \
55 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
56 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
57 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
58 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
59 .
60 docker build $(DOCKER_BUILD_ARGS) \
61 --target ${ENB_NAME} \
62 --tag ${ENB_IMAGENAME} \
63 --file Dockerfile.enb \
64 --build-arg build_base=${BASE_IMAGENAME} \
Hyunsun Moon3386a852019-07-26 14:56:11 -060065 --build-arg org_label_schema_version="${VERSION}" \
66 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
67 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
68 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
69 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
70 .
71
72docker-push:
Hyunsun Moon9e87a152019-07-27 04:47:46 -060073 docker push ${BASE_IMAGENAME}
Hyunsun Moon3386a852019-07-26 14:56:11 -060074 docker push ${UE_IMAGENAME}
Hyunsun Moon9e87a152019-07-27 04:47:46 -060075 docker push ${ENB_IMAGENAME}
Hyunsun Moon3386a852019-07-26 14:56:11 -060076
77test: docker-build
78
79.PHONY: docker-build docker-push test