Unverified Commit f245bb5b authored by Alexader's avatar Alexader Committed by GitHub

Merge pull request #12 from meshplus/feat/add-dockerfile

feat(Dockerfile): add dockerfile to build pier with fabric plugin
parents 944d7092 69dc9f85
FROM golang:1.14.2 as builder
RUN mkdir -p /go/src/github.com/meshplus/pier
RUN mkdir -p /go/src/github.com/meshplus/pier-client-fabric
WORKDIR /go/src/github.com/meshplus/pier
# Cache dependencies
COPY go.mod ../pier-client-fabric/
COPY go.sum ../pier-client-fabric/
COPY build/pier/go.mod .
COPY build/pier/go.sum .
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download -x
#RUN apk add make
# Build real binaries
COPY build/pier .
COPY . ../pier-client-fabric/
RUN go get -u github.com/gobuffalo/packr/packr
RUN make install
RUN cd ../pier-client-fabric && \
make fabric1.4 && \
cp build/fabric-client-1.4.so /go/bin/fabric-client-1.4.so
# Final image
FROM frolvlad/alpine-glibc
WORKDIR /root
# Copy over binaries from the builder
COPY --from=builder /go/bin/pier /usr/local/bin
COPY ./build/pier/build/libwasmer.so /lib
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib
RUN ["pier", "init"]
RUN mkdir -p /root/.pier/plugins
COPY --from=builder /go/bin/*.so /root/.pier/plugins/
COPY config/validating.wasm /root/.pier/validating.wasm
COPY scripts/docker_entrypoint.sh /root/docker_entrypoint.sh
RUN chmod +x /root/docker_entrypoint.sh
COPY config /root/.pier/fabric
COPY config/pier.toml /root/.pier/pier.toml
ENV APPCHAIN_NAME=fabric
EXPOSE 44555 44544
ENTRYPOINT ["/root/docker_entrypoint.sh", "$APPCHAIN_NAME"]
......@@ -20,10 +20,15 @@ fabric1.4:
mkdir -p build
$(GO) build --buildmode=plugin -o build/fabric-client-1.4.so ./*.go
docker:
mkdir -p build
cd build && rm -rf pier && cp -r ../../pier pier
cd ${CURRENT_PATH}
docker build -t meshplus/pier-fabric .
fabric1.4-linux:
cd scripts && sh cross_compile.sh linux-amd64 ${CURRENT_PATH}
## make linter: Run golanci-lint
linter:
golangci-lint run
......@@ -289,11 +289,8 @@ func (c *Client) SubmitIBTP(ibtp *pb.IBTP) (*model.PluginResponse, error) {
newArgs = append(newArgs, content.Args[0])
newArgs = append(newArgs, result...)
case "interchainCharge":
newArgs = append(newArgs, []byte("false"))
if response.OK {
newArgs[0] = []byte("true")
}
newArgs = append(newArgs, []byte(fmt.Sprintf("%s-%d", ibtp.To, ibtp.Index)))
newArgs = append(newArgs, []byte(strconv.FormatBool(response.OK)), content.Args[0])
newArgs = append(newArgs, content.Args[2:]...)
}
ret.Result, err = c.generateCallback(ibtp, newArgs, proof)
......
......@@ -125,7 +125,7 @@ organizations:
#
orderers:
orderer.example.com:
url: grpcs://10.1.16.48:7050
url: grpcs://host.docker.internal:7050
# these are standard properties defined by the gRPC library
# they will be passed in as-is to gRPC client constructor
......@@ -152,8 +152,8 @@ orderers:
peers:
peer0.org1.example.com:
# this URL is used to send endorsement and query requests
url: grpcs://10.1.16.48:7051
eventUrl: grpcs://10.1.16.48:7053
url: grpcs://host.docker.internal:7051
eventUrl: grpcs://host.docker.internal:7053
grpcOptions:
ssl-target-name-override: peer0.org1.example.com
# These parameters should be set in coordination with the keepalive policy on the server,
......@@ -172,8 +172,8 @@ peers:
peer1.org1.example.com:
# this URL is used to send endorsement and query requests
url: grpcs://10.1.16.48:8051
eventUrl: grpcs://10.1.16.48:8053
url: grpcs://host.docker.internal:8051
eventUrl: grpcs://host.docker.internal:8053
grpcOptions:
ssl-target-name-override: peer1.org1.example.com
# These parameters should be set in coordination with the keepalive policy on the server,
......@@ -192,8 +192,8 @@ peers:
peer0.org2.example.com:
# this URL is used to send endorsement and query requests
url: grpcs://10.1.16.48:9051
eventUrl: grpcs://10.1.16.48:9053
url: grpcs://host.docker.internal:9051
eventUrl: grpcs://host.docker.internal:9053
grpcOptions:
ssl-target-name-override: peer0.org2.example.com
# These parameters should be set in coordination with the keepalive policy on the server,
......@@ -212,8 +212,8 @@ peers:
peer1.org2.example.com:
# this URL is used to send endorsement and query requests
url: grpcs://10.1.16.48:10051
eventUrl: grpcs://10.1.16.48:10053
url: grpcs://host.docker.internal:10051
eventUrl: grpcs://host.docker.internal:10053
grpcOptions:
ssl-target-name-override: peer1.org2.example.com
# These parameters should be set in coordination with the keepalive policy on the server,
......@@ -270,27 +270,27 @@ peers:
entityMatchers:
peer:
- pattern: (\w*)peer0.org1.example.com:(\w*)
urlSubstitutionExp: grpcs://10.1.16.48:7051
eventUrlSubstitutionExp: grpcs://10.1.16.48:7053
urlSubstitutionExp: grpcs://host.docker.internal:7051
eventUrlSubstitutionExp: grpcs://host.docker.internal:7053
sslTargetOverrideUrlSubstitutionExp: peer0.org1.example.com
mappedHost: peer0.org1.example.com
- pattern: (\w*)peer1.org1.example.com:(\w*)
urlSubstitutionExp: grpcs://10.1.16.48:8051
eventUrlSubstitutionExp: grpcs://10.1.16.48:8053
urlSubstitutionExp: grpcs://host.docker.internal:8051
eventUrlSubstitutionExp: grpcs://host.docker.internal:8053
sslTargetOverrideUrlSubstitutionExp: peer1.org1.example.com
mappedHost: peer1.org1.example.com
- pattern: (\w*)peer0.org2.example.com:(\w*)
urlSubstitutionExp: grpcs://10.1.16.48:9051
eventUrlSubstitutionExp: grpcs://10.1.16.48:9053
urlSubstitutionExp: grpcs://host.docker.internal:9051
eventUrlSubstitutionExp: grpcs://host.docker.internal:9053
sslTargetOverrideUrlSubstitutionExp: peer0.org2.example.com
mappedHost: peer0.org2.example.com
- pattern: (\w*)peer1.org2.example.com:(\w*)
urlSubstitutionExp: grpcs://10.1.16.48:10051
eventUrlSubstitutionExp: grpcs://10.1.16.48:10053
urlSubstitutionExp: grpcs://host.docker.internal:10051
eventUrlSubstitutionExp: grpcs://host.docker.internal:10053
sslTargetOverrideUrlSubstitutionExp: peer1.org2.example.com
mappedHost: peer1.org2.example.com
......@@ -323,6 +323,6 @@ entityMatchers:
#entityMatchers:
orderer:
- pattern: (\w*)orderer.example.com(\w*)
urlSubstitutionExp: grpcs://10.1.16.48:7050
urlSubstitutionExp: grpcs://host.docker.internal:7050
sslTargetOverrideUrlSubstitutionExp: orderer.example.com
mappedHost: orderer.example.com
addr = "localhost:7053"
addr = "host.docker.internal:7053"
event_filter = "interchain-event-name"
username = "Admin"
ccid = "broker"
......
title = "Pier"
[port]
http = 44544
pprof = 44555
[log]
level = "debug"
dir = "logs"
filename = "pier.log"
report_caller = false
[mode]
type = "relay" # relay or direct
[mode.relay]
addr = "host.docker.internal:60011"
quorum = 2
validators = [
"0x000f1a7a08ccc48e5d30f80850cf1cf283aa3abd",
"0xe93b92f1da08f925bdee44e91e7768380ae83307",
"0xb18c8575e3284e79b92100025a31378feb8100d6",
"0x856E2B9A5FA82FD1B031D1FF6863864DBAC7995D",
]
[mode.direct]
peers = [
#"/ip4/host.docker.internal/tcp/4002/p2p/Qmf4fn6sT3yLh3uqJnJ453yAhzpccbCQ75XfnBURTD3NoR",
"/ip4/host.docker.internal/tcp/4003/p2p/QmS78YUNXbxjaKivSygyDkxjZXedYy4TF6vfAJRPMRYdZ8",
"/ip4/host.docker.internal/tcp/4004/p2p/QmZpeCcBQBaurf8SUEvxjRY1nLYAHHUzqWLEXd4uoiuE9K"
]
[appchain]
plugin = "fabric-client-1.4.so"
config = "fabric"
......@@ -196,6 +196,9 @@ func (broker *Broker) InterchainInvoke(stub shim.ChaincodeStubInterface, args []
}
txValue, err := json.Marshal(tx)
if err != nil {
return shim.Error(err.Error())
}
// persist out message
key := broker.outMsgKey(tx.DstChainID, strconv.FormatUint(tx.Index, 10))
......
......@@ -23,7 +23,7 @@ require (
replace github.com/golang/protobuf => github.com/golang/protobuf v1.3.2
replace google.golang.org/grpc => google.golang.org/grpc v1.28.1
replace google.golang.org/grpc => google.golang.org/grpc v1.27.1
replace gopkg.in/yaml.v2 => gopkg.in/yaml.v2 v2.2.7
......@@ -33,6 +33,8 @@ replace github.com/meshplus/pier => ../pier
replace golang.org/x/text => golang.org/x/text v0.3.0
replace golang.org/x/sys => golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f
replace github.com/spf13/afero => github.com/spf13/afero v1.1.2
replace github.com/spf13/pflag => github.com/spf13/pflag v1.0.5
......
......@@ -97,6 +97,7 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
......@@ -282,6 +283,7 @@ github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/hyperledger/fabric v2.0.1+incompatible h1:7W+yG0gLKTC7NLcWPT3vfpnaseztPpH9wXGfAW7yvBs=
github.com/hyperledger/fabric v2.0.1+incompatible/go.mod h1:tGFAOCT696D3rG0Vofd2dyWYLySHlh0aQjf7Q1HAju0=
github.com/hyperledger/fabric v2.1.1+incompatible h1:cYYRv3vVg4kA6DmrixLxwn1nwBEUuYda8DsMwlaMKbY=
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a h1:HgdNn3UYz8PdcZrLEk0IsSU4LRHp7yY2rgjIKcSiJaA=
github.com/hyperledger/fabric-amcl v0.0.0-20200128223036-d1aa2665426a/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
github.com/hyperledger/fabric-chaincode-go v0.0.0-20200511190512-bcfeb58dd83a h1:KoFw2HnRfW+EItMP0zvUUl1FGzDb/7O0ov7uXZffQok=
......@@ -878,6 +880,7 @@ google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c h1:hrpEMCZ2O7DR5gC
google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20200218151345-dad8c97a84f5 h1:jB9+PJSvu5tBfmJHy/OVapFdjDF3WvpkqRhxqrmzoEU=
google.golang.org/genproto v0.0.0-20200218151345-dad8c97a84f5/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k=
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
......
#!/usr/bin/env sh
set -e
APPCHAIN_NAME=$1
pier --repo=/root/.pier appchain register --name=${APPCHAIN_NAME} --type=fabric --validators=/root/.pier/fabric/fabric.validators --desc="appchain for test" --version=1.4.3
pier --repo=/root/.pier rule deploy --path=/root/.pier/validating.wasm
pier --repo=/root/.pier start
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment