This repository has been archived by the owner on Mar 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
147 lines (117 loc) · 4.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright SecureKey Technologies Inc. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# Supported Targets:
#
# all: runs code checks and unit tests
# clean: cleans the build area
# checks: runs code checks (license, spelling, lint)
# unit-test: runs unit tests
# populate-fixtures: populate crypto directory and channel configuration for bddtests
# crypto-gen: generates crypto directory
# channel-config-gen: generates test channel configuration transactions and blocks
# bddtests: run bddtests
# docker-thirdparty: pulls thirdparty images
# generate: generates mocks
#
# Tool commands (overridable)
DOCKER_CMD ?= docker
GO_CMD ?= go
ALPINE_VER ?= 3.12
DBUILD_CMD ?= docker build
# defined in github.com/hyperledger/fabric/common/metadata/metadata.go
FABRIC_METADATA_VAR = Version=2.2.1
# Build flags
GO_TAGS ?=
GO_LDFLAGS ?= $(FABRIC_METADATA_VAR:%=-X github.com/hyperledger/fabric/common/metadata.%)
# Local variables used by makefile
PROJECT_NAME = sidetree-fabric
CONTAINER_IDS = $(shell docker ps -a -q)
DEV_IMAGES = $(shell docker images dev-* -q)
ARCH = $(shell go env GOARCH)
GO_VER = 1.14.4
export GO111MODULE = on
# Fabric tools docker image (overridable)
FABRIC_TOOLS_IMAGE ?= hyperledger/fabric-tools
# TODO: fabric-sdk-go fails when using artifacts generated by fabric-tools v2.0.0. Switch to fabric-tools v2.0.0 after the SDK is fixed.
# FABRIC_TOOLS_VERSION ?= 2.0.0
FABRIC_TOOLS_VERSION ?= 2.0.0-alpha
FABRIC_TOOLS_TAG ?= $(ARCH)-$(FABRIC_TOOLS_VERSION)
# Fabric peer ext docker image (overridable)
FABRIC_PEER_IMAGE ?= hyperledger/fabric-peer
FABRIC_PEER_VERSION ?= 2.2.1
FABRIC_PEER_TAG ?= $(ARCH)-$(FABRIC_PEER_VERSION)
export FABRIC_CLI_EXT_VERSION ?= v0.1.5
# Namespace for the Sidetree Fabric peer image
DOCKER_OUTPUT_NS ?= ghcr.io/trustbloc
SIDETREE_FABRIC_IMAGE_NAME ?= sidetree-fabric
SIDETREE_FABRIC_IMAGE_TAG ?= latest
checks: license lint
.PHONY: license
license:
@scripts/check_license.sh
lint:
@scripts/check_lint.sh
unit-test: checks
@scripts/unit.sh
generate:
go generate ./...
all: clean checks unit-test bddtests
crypto-gen:
@echo "Generating crypto directory ..."
@$(DOCKER_CMD) run -i \
-v /$(abspath .):/opt/workspace/$(PROJECT_NAME) -u $(shell id -u):$(shell id -g) \
$(FABRIC_TOOLS_IMAGE):$(FABRIC_TOOLS_TAG) \
//bin/bash -c "FABRIC_VERSION_DIR=fabric /opt/workspace/${PROJECT_NAME}/scripts/generate_crypto.sh"
channel-config-gen:
@echo "Generating test channel configuration transactions and blocks ..."
@$(DOCKER_CMD) run -i \
-v /$(abspath .):/opt/workspace/$(PROJECT_NAME) -u $(shell id -u):$(shell id -g) \
$(FABRIC_TOOLS_IMAGE):$(FABRIC_TOOLS_TAG) \
//bin/bash -c "FABRIC_VERSION_DIR=fabric/ /opt/workspace/${PROJECT_NAME}/scripts/generate_channeltx.sh"
populate-fixtures:
@scripts/populate-fixtures.sh -f
bddtests: clean populate-fixtures docker-thirdparty fabric-peer-docker build-cc fabric-cli
@scripts/integration.sh
fabric-peer:
@echo "Building fabric-peer"
@mkdir -p ./.build/bin
@cd cmd/peer && go build -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" \
-o ../../.build/bin/fabric-peer main.go
fabric-peer-docker:
@echo "Building fabric-peer image"
@$(DBUILD_CMD) \
-f ./images/fabric-peer/Dockerfile --no-cache \
-t $(DOCKER_OUTPUT_NS)/$(SIDETREE_FABRIC_IMAGE_NAME):$(SIDETREE_FABRIC_IMAGE_TAG) \
--build-arg FABRIC_PEER_UPSTREAM_IMAGE=$(FABRIC_PEER_IMAGE) \
--build-arg FABRIC_PEER_UPSTREAM_TAG=$(FABRIC_PEER_TAG) \
--build-arg ALPINE_VER=$(ALPINE_VER) \
--build-arg GO_VER=$(GO_VER) \
--build-arg GO_LDFLAGS="$(GO_LDFLAGS)" \
--build-arg GO_TAGS="$(GO_TAGS)" .
docker-thirdparty:
docker pull couchdb:3.1
docker pull hyperledger/fabric-orderer:$(ARCH)-2.2.0
build-cc:
@echo "Building cc"
@mkdir -p ./.build
@scripts/copycc.sh
fabric-cli:
@scripts/build_fabric_cli.sh
clean-images:
@echo "Stopping all containers, pruning containers and images, deleting dev images"
ifneq ($(strip $(CONTAINER_IDS)),)
@docker stop $(CONTAINER_IDS)
endif
@docker system prune -f
ifneq ($(strip $(DEV_IMAGES)),)
@docker rmi $(DEV_IMAGES) -f
endif
clean:
rm -Rf ./test/bddtests/docker-compose.log
rm -Rf ./test/bddtests/fixtures/fabric/channel
rm -Rf ./test/bddtests/fixtures/fabric/crypto-config
rm -Rf ./.build
rm -Rf ./test/bddtests/.fabriccli