blob: 4ceae91459989ee6b41640a94c227345aa4c23d1 [file] [log] [blame]
Dinesh Belwalkare1e85ad2019-07-31 23:06:47 +00001# Copyright 2018-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Scott Bakerbdb962b2020-04-03 10:53:36 -070015# Configure shell
16SHELL = bash -eu -o pipefail
17
18# Variables
19VERSION ?= $(shell cat ../VERSION)
20CONTAINER_NAME ?= redfish-importer-demotest
21
22## Docker related
23DOCKER_REGISTRY ?=
24DOCKER_REPOSITORY ?=
25DOCKER_BUILD_ARGS ?=
26DOCKER_TAG ?= ${VERSION}
27DOCKER_IMAGENAME := ${DOCKER_REGISTRY}${DOCKER_REPOSITORY}${CONTAINER_NAME}:${DOCKER_TAG}
28
29## Docker labels. Only set ref and commit date if committed
30DOCKER_LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
31DOCKER_LABEL_VCS_REF ?= $(shell git diff-index --quiet HEAD -- && git rev-parse HEAD || echo "unknown")
32DOCKER_LABEL_COMMIT_DATE ?= $(shell git diff-index --quiet HEAD -- && git show -s --format=%cd --date=iso-strict HEAD || echo "unknown" )
33DOCKER_LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
34
Dinesh Belwalkare1e85ad2019-07-31 23:06:47 +000035prereq:
36 go get -v google.golang.org/grpc
37 go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
38 go get -v github.com/golang/protobuf/protoc-gen-go
Dinesh Belwalkare63f7f92019-11-22 23:11:16 +000039 go get github.com/sirupsen/logrus
Dinesh Belwalkare1e85ad2019-07-31 23:06:47 +000040 go get github.com/Shopify/sarama
41
42demotest: prereq proto/importer.pb.go
43 go build -i -v -o $@
44
Dinesh Belwalkare1e85ad2019-07-31 23:06:47 +000045proto/importer.pb.go: ../proto/importer.proto
Dinesh Belwalkarb5db83f2019-10-24 17:27:58 +000046 mkdir -p proto
Dinesh Belwalkare1e85ad2019-07-31 23:06:47 +000047 protoc --proto_path=../proto \
48 -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
49 --go_out=plugins=grpc:proto/ \
50 ../proto/importer.proto
Scott Bakerbdb962b2020-04-03 10:53:36 -070051
52docker-build:
53 docker build $(DOCKER_BUILD_ARGS) \
54 -t ${DOCKER_IMAGENAME} \
55 --build-arg org_label_schema_version="${VERSION}" \
56 --build-arg org_label_schema_vcs_url="${DOCKER_LABEL_VCS_URL}" \
57 --build-arg org_label_schema_vcs_ref="${DOCKER_LABEL_VCS_REF}" \
58 --build-arg org_label_schema_build_date="${DOCKER_LABEL_BUILD_DATE}" \
59 --build-arg org_opencord_vcs_commit_date="${DOCKER_LABEL_COMMIT_DATE}" \
60 -f Dockerfile ..
61
62docker-push:
63 docker push ${DOCKER_IMAGENAME}