Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 1 | # Copyright 2018-present Open Networking Foundation |
Dinesh Belwalkar | 6c0bc75 | 2020-04-24 23:47:53 +0000 | [diff] [blame] | 2 | # Copyright 2018-present Edgecore Networks Corporation |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 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 | |
Scott Baker | bdb962b | 2020-04-03 10:53:36 -0700 | [diff] [blame] | 16 | # Configure shell |
| 17 | SHELL = bash -eu -o pipefail |
| 18 | |
| 19 | # Variables |
| 20 | VERSION ?= $(shell cat ../VERSION) |
| 21 | CONTAINER_NAME ?= redfish-importer-demotest |
| 22 | |
| 23 | ## Docker related |
| 24 | DOCKER_REGISTRY ?= |
| 25 | DOCKER_REPOSITORY ?= |
| 26 | DOCKER_BUILD_ARGS ?= |
| 27 | DOCKER_TAG ?= ${VERSION} |
| 28 | DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG} |
| 29 | |
| 30 | ## Docker labels. Only set ref and commit date if committed |
| 31 | DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 32 | DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown") |
| 33 | DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" ) |
| 34 | DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 35 | |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 36 | prereq: |
| 37 | go get -v google.golang.org/grpc |
| 38 | go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway |
| 39 | go get -v github.com/golang/protobuf/protoc-gen-go |
Dinesh Belwalkar | e63f7f9 | 2019-11-22 23:11:16 +0000 | [diff] [blame] | 40 | go get github.com/sirupsen/logrus |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 41 | go get github.com/Shopify/sarama |
| 42 | |
Scott Baker | 105df15 | 2020-04-13 15:55:14 -0700 | [diff] [blame^] | 43 | demotest: proto/importer.pb.go |
| 44 | GO111MODULE=on go build -mod=vendor -i -v -o $@ |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 45 | |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 46 | proto/importer.pb.go: ../proto/importer.proto |
Dinesh Belwalkar | b5db83f | 2019-10-24 17:27:58 +0000 | [diff] [blame] | 47 | mkdir -p proto |
Dinesh Belwalkar | e1e85ad | 2019-07-31 23:06:47 +0000 | [diff] [blame] | 48 | protoc --proto_path=../proto \ |
| 49 | -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ |
| 50 | --go_out=plugins=grpc:proto/ \ |
| 51 | ../proto/importer.proto |
Scott Baker | bdb962b | 2020-04-03 10:53:36 -0700 | [diff] [blame] | 52 | |
| 53 | docker-build: |
| 54 | docker build $(DOCKER_BUILD_ARGS) \ |
| 55 | -t ${DOCKER_IMAGENAME} \ |
| 56 | --build-arg org_label_schema_version="${VERSION}" \ |
| 57 | --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \ |
| 58 | --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \ |
| 59 | --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \ |
| 60 | --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \ |
| 61 | -f Dockerfile .. |
| 62 | |
| 63 | docker-push: |
| 64 | docker push ${DOCKER_IMAGENAME} |