Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCAAS Builders #3315

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ $(BUILD_DIR)/bin/%:
@touch $@

.PHONY: docker
docker: $(RELEASE_IMAGES:%=%-docker)
docker: $(RELEASE_IMAGES:%=%-docker) ccaasbuilder

.PHONY: $(RELEASE_IMAGES:%=%-docker)
$(RELEASE_IMAGES:%=%-docker): %-docker: $(BUILD_DIR)/images/%/$(DUMMY)
Expand Down Expand Up @@ -265,7 +265,7 @@ release-all: check-go-version $(RELEASE_PLATFORMS:%=release/%)
.PHONY: $(RELEASE_PLATFORMS:%=release/%)
$(RELEASE_PLATFORMS:%=release/%): GO_LDFLAGS = $(METADATA_VAR:%=-X $(PKGNAME)/common/metadata.%)
$(RELEASE_PLATFORMS:%=release/%): release/%: $(foreach exe,$(RELEASE_EXES),release/%/bin/$(exe))
$(RELEASE_PLATFORMS:%=release/%): ccaasbuilder
$(RELEASE_PLATFORMS:%=release/%): release/%: ccaasbuilder/%

# explicit targets for all platform executables
$(foreach platform, $(RELEASE_PLATFORMS), $(RELEASE_EXES:%=release/$(platform)/bin/%)):
Expand Down Expand Up @@ -347,11 +347,18 @@ docs:
@docker run --rm -v $$(pwd):/docs n42org/tox:3.4.0 sh -c 'cd /docs && tox -e docs'

.PHONY: ccaasbuilder-clean
ccaasbuilder-clean:
rm -rf $(MARCH:%=release/%)/bin/ccaas_builder
ccaasbuilder-clean/%:
$(eval platform = $(patsubst ccaasbuilder/%,%,$@) )
cd ccaas_builder && rm -rf $(strip $(platform))

.PHONY: ccaasbuilder
ccaasbuilder: ccaasbuilder-clean
cd ccaas_builder && go test -v ./cmd/detect && go build -o ../$(MARCH:%=release/%)/bin/ccaas_builder/bin/ -buildvcs=false ./cmd/detect/
cd ccaas_builder && go test -v ./cmd/build && go build -o ../$(MARCH:%=release/%)/bin/ccaas_builder/bin/ -buildvcs=false ./cmd/build/
cd ccaas_builder && go test -v ./cmd/release && go build -o ../$(MARCH:%=release/%)/bin/ccaas_builder/bin/ -buildvcs=false ./cmd/release/
ccaasbuilder/%: ccaasbuilder-clean
$(eval platform = $(patsubst ccaasbuilder/%,%,$@) )
$(eval GOOS = $(word 1,$(subst -, ,$(platform))))
$(eval GOARCH = $(word 2,$(subst -, ,$(platform))))
@mkdir -p ../release/$(strip $(platform))/builders/ccaas/bin
cd ccaas_builder && go test -v ./cmd/detect && GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ../release/$(strip $(platform))/builders/ccaas/bin/ ./cmd/detect/
cd ccaas_builder && go test -v ./cmd/build && GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ../release/$(strip $(platform))/builders/ccaas/bin/ ./cmd/build/
cd ccaas_builder && go test -v ./cmd/release && GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ../release/$(strip $(platform))/builders/ccaas/bin/ ./cmd/release/

ccaasbuilder: ccaasbuilder/$(MARCH)
11 changes: 8 additions & 3 deletions ci/scripts/create_binary_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
set -euo pipefail

make "release/${TARGET}"
mkdir "release/${TARGET}/config"
mv sampleconfig/*yaml "release/${TARGET}/config"
mkdir -p "release/${TARGET}/config"
mkdir -p "release/${TARGET}/builders/ccaas"

# cp not move otherwise this breaks your source tree
cp sampleconfig/*yaml "release/${TARGET}/config"
cp ccaas_builder/bin/${TARGET}/* "release/${TARGET}/builders/ccaas"

cd "release/${TARGET}"
if [ "$TARGET" == "windows-amd64" ]; then
for FILE in bin/*; do mv $FILE $FILE.exe; done
fi
tar -czvf "hyperledger-fabric-${TARGET}-${RELEASE}.tar.gz" bin config
tar -czvf "hyperledger-fabric-${TARGET}-${RELEASE}.tar.gz" bin config builders
2 changes: 1 addition & 1 deletion images/peer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ VOLUME /var/hyperledger
COPY --from=peer /go/src/github.com/hyperledger/fabric/build/bin /usr/local/bin
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/msp ${FABRIC_CFG_PATH}/msp
COPY --from=peer /go/src/github.com/hyperledger/fabric/sampleconfig/core.yaml ${FABRIC_CFG_PATH}/core.yaml
COPY --from=peer /go/src/github.com/hyperledger/fabric/release/linux-amd64/bin/ccaas_builder/bin/ /opt/hyperledger/ccaas_builder/bin/
COPY --from=peer /go/src/github.com/hyperledger/fabric/release/linux-amd64/builders/ccaas/bin/ /opt/hyperledger/ccaas_builder/bin/
EXPOSE 7051
CMD ["peer","node","start"]
2 changes: 2 additions & 0 deletions integration/externalbuilders/binary/bin/detect
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ if [ "$(jq -r .type "$META/metadata.json")" == "binary" ]; then
exit 0
fi

>&2 cat $META/metadata.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to leave this in?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I didn't but then it was useful in debugging - as later on the peer lies about what the language really is.
(i.e. it toUpperCase() the language - so I first assumed the packaging of the contract was wrong

>&2 echo "binary is the only supported type"

exit 1
2 changes: 1 addition & 1 deletion integration/nwo/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func New(c *Config, rootDir string, dockerClient *docker.Client, startPort int,
Name: "binary",
PropagateEnvironment: []string{"GOPROXY"},
}, {
Path: filepath.Join(cwd, "..", "..", "release", fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH), "bin", "ccaas_builder"),
Path: filepath.Join(cwd, "..", "..", "release", fmt.Sprintf("%s-%s", runtime.GOOS, runtime.GOARCH), "builders", "ccaas"),
Name: "ccaas",
PropagateEnvironment: []string{"CHAINCODE_AS_A_SERVICE_BUILDER_CONFIG"},
}}
Expand Down