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) |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 18 | BASE_NAME ?= oai-base |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 19 | UE_NAME ?= lte-uesoftmodem |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 20 | ENB_NAME ?= lte-softmodem |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 21 | |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 22 | # Tag is fixed to OAI release version, v1.0.0, regardless of VERSION file |
| 23 | DOCKER_TAG ?= 1.0.0 |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 24 | DOCKER_REGISTRY ?= |
| 25 | DOCKER_REPOSITORY ?= |
| 26 | DOCKER_BUILD_ARGS ?= |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 27 | BASE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${BASE_NAME}:${DOCKER_TAG} |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 28 | UE_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${UE_NAME}:${DOCKER_TAG} |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 29 | ENB_IMAGENAME ?= ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${ENB_NAME}:${DOCKER_TAG} |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 30 | |
| 31 | ## Docker labels. Only set ref and commit date if committed |
| 32 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 33 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 34 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 35 | DOCKER_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 |
| 38 | docker-build: |
| 39 | docker build $(DOCKER_BUILD_ARGS) \ |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 40 | --target ${BASE_NAME} \ |
| 41 | --tag ${BASE_IMAGENAME} \ |
| 42 | --file Dockerfile.base \ |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 43 | --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 Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 52 | --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 Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 65 | --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 | |
| 72 | docker-push: |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 73 | docker push ${BASE_IMAGENAME} |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 74 | docker push ${UE_IMAGENAME} |
Hyunsun Moon | 9e87a15 | 2019-07-27 04:47:46 -0600 | [diff] [blame] | 75 | docker push ${ENB_IMAGENAME} |
Hyunsun Moon | 3386a85 | 2019-07-26 14:56:11 -0600 | [diff] [blame] | 76 | |
| 77 | test: docker-build |
| 78 | |
| 79 | .PHONY: docker-build docker-push test |