-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmakefile
75 lines (61 loc) · 3.05 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
DOCKER_IMAGE_NAME ?= weaver-fabric-driver
DOCKER_TAG ?= `cat ./VERSION`
DOCKER_REGISTRY ?= ghcr.io/hyperledger-labs
GIT_URL = https://github.com/hyperledger-labs/weaver-dlt-interoperability/core/drivers/fabric-driver
NETWORK_NAME ?= network1
COMPOSE_ARG ?=
build: .npmrc
npm install
npm run build
protos-js:
mkdir -p protos-js && \
cp -r ../../../common/protos-js/common ./protos-js/ && \
cp -r ../../../common/protos-js/corda ./protos-js/ && \
cp -r ../../../common/protos-js/driver ./protos-js/ && \
cp -r ../../../common/protos-js/fabric ./protos-js/ && \
cp -r ../../../common/protos-js/identity ./protos-js/ && \
cp -r ../../../common/protos-js/msp ./protos-js/ && \
cp -r ../../../common/protos-js/networks ./protos-js/ && \
cp -r ../../../common/protos-js/peer ./protos-js/ && \
cp -r ../../../common/protos-js/relay ./protos-js/ && \
cp -r ../../../common/protos-js/package.json ./protos-js/
weaver-fabric-interop-sdk: protos-js
mkdir -p weaver-fabric-interop-sdk && \
cp -r ../../../sdks/fabric/interoperation-node-sdk/build ./weaver-fabric-interop-sdk/ && \
cp -r ../../../sdks/fabric/interoperation-node-sdk/index.js ./weaver-fabric-interop-sdk/ && \
cp -r ../../../sdks/fabric/interoperation-node-sdk/package.json ./weaver-fabric-interop-sdk/package.json
build-local: weaver-fabric-interop-sdk
cp package.json package-remote.json
cp package-local.json package.json
(npm install --unsafe-perm) || \
(mv package-remote.json package.json && exit 1) # Only if fails
mv package-remote.json package.json # Only if success
npm run build
build-image-local: weaver-fabric-interop-sdk
cp package.json package-remote.json
cp package-local.json package.json
(docker build --build-arg BUILD_TAG="local" --build-arg GIT_URL=$(GIT_URL) -t ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) -f fabricDriver.dockerfile.local . ) || \
(mv package-remote.json package.json && exit 1) # Only if fails
mv package-remote.json package.json # Only if success
rm -rf protos-js weaver-fabric-interop-sdk
docker tag ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) $(DOCKER_IMAGE_NAME):latest
build-image: .npmrc
docker build --build-arg BUILD_TAG="remote" --build-arg GIT_URL=$(GIT_URL) -t ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) -f fabricDriver.dockerfile .
check-if-tag-exists:
!(DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_TAG) > /dev/null)
push-image: check-if-tag-exists build-image
docker tag ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_TAG)
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_TAG)
push-image-latest:
docker tag ${DOCKER_IMAGE_NAME}:$(DOCKER_TAG) $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):latest
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):latest
deploy:
mkdir -p wallet-$(NETWORK_NAME) && chmod 777 wallet-$(NETWORK_NAME)
docker compose $(COMPOSE_ARG) up -d
stop:
docker compose $(COMPOSE_ARG) down
re-deploy: stop deploy
clean:
rm -rf node_modules package-lock.json out
clean-local:
rm -rf node_modules package-lock.json out protos-js weaver-fabric-interop-sdk