Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame^] | 1 | # |
| 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 | |
| 17 | VERSION ?= $(shell cat ./VERSION) |
| 18 | ENB_NAME ?= lte-softmodem |
| 19 | UE_NAME ?= lte-uesoftmodem |
| 20 | |
| 21 | DOCKER_TAG ?= ${VERSION} |
| 22 | DOCKER_REGISTRY ?= |
| 23 | DOCKER_REPOSITORY ?= |
| 24 | DOCKER_BUILD_ARGS ?= |
| 25 | ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG} |
| 26 | UE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${UE_NAME}:${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") |
| 33 | |
| 34 | # https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target |
| 35 | docker-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 | |
| 55 | docker-push: |
| 56 | docker push ${ENB_IMAGENAME} |
| 57 | docker push ${UE_IMAGENAME} |
| 58 | |
| 59 | test: docker-build |
| 60 | |
| 61 | .PHONY: docker-build docker-push test |