Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 6fc51ab

Browse files
authored
Merge pull request #100 from target/aahmed-product-deployment
Add product to Dockerfile/docker-compose
2 parents ace029e + 54f1d71 commit 6fc51ab

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

contracts/product/Dockerfile

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright (c) 2019 Target Brands, Inc.
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+
15+
FROM ubuntu:bionic as GRID-PRODUCT-BUILDER
16+
17+
RUN apt-get update \
18+
&& apt-get install gnupg -y
19+
20+
# Install base dependencies
21+
RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \
22+
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
23+
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
24+
&& apt-get update \
25+
&& apt-get install -y -q \
26+
build-essential \
27+
curl \
28+
gcc \
29+
g++ \
30+
libpq-dev \
31+
libssl-dev \
32+
libsasl2-dev \
33+
libzmq3-dev \
34+
openssl \
35+
pkg-config \
36+
sabre-cli \
37+
unzip \
38+
&& apt-get clean \
39+
&& rm -rf /var/lib/apt/lists/*
40+
41+
ENV PATH=$PATH:/protoc3/bin:/root/.cargo/bin
42+
43+
# Install Rust
44+
RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
45+
&& chmod +x /usr/bin/rustup-init \
46+
&& rustup-init -y
47+
48+
RUN rustup update \
49+
&& rustup default \
50+
&& rustup target add wasm32-unknown-unknown --toolchain stable
51+
52+
# For Building Protobufs
53+
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip \
54+
&& unzip -o protoc-3.5.1-linux-x86_64.zip -d /usr/local \
55+
&& rm protoc-3.5.1-linux-x86_64.zip
56+
57+
COPY ./sdk /sdk
58+
59+
RUN mkdir contracts \
60+
&& USER=root cargo new --bin contracts/product
61+
WORKDIR /contracts/product
62+
63+
# Build TP with dummy source in order to cache dependencies in Docker image.
64+
COPY ./contracts/product/Cargo.toml ./Cargo.toml
65+
RUN cargo build --release
66+
67+
COPY contracts/product/Cargo.toml contracts/product/Cargo.lock* ./
68+
RUN cargo build
69+
70+
RUN rm src/*.rs
71+
COPY ./contracts/product/src ./src
72+
73+
RUN rm ./target/release/grid-product-tp* ./target/release/deps/grid_product*
74+
RUN cargo build --target wasm32-unknown-unknown --release
75+
76+
COPY ./contracts/product/product.yaml ./product.yaml
77+
78+
ENTRYPOINT []

contracts/product/product.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2019 Target Brands, Inc.
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+
15+
name: grid_product
16+
version: '1.0'
17+
wasm: target/wasm32-unknown-unknown/release/grid-product-tp.wasm
18+
inputs:
19+
- '621dee01'
20+
- '621dee02'
21+
- 'cad11d'
22+
outputs:
23+
- '621dee02'

docker-compose.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ services:
7676
sabre perm cad11d pike --key /grid-shared/my_key --read --write --url http://grid-sawtooth-rest-api:8008 --wait 30
7777
echo '---------========= pike contract is loaded =========---------'
7878
"
79+
80+
product-contract-builder:
81+
image: product-contract-builder
82+
container_name: product-contract-builder
83+
build:
84+
context: .
85+
dockerfile: contracts/product/Dockerfile
86+
volumes:
87+
- grid-shared:/grid-shared
88+
entrypoint: |
89+
bash -c "
90+
while true; do curl -s http://grid-sawtooth-rest-api:8008/state | grep -q head; if [ $$? -eq 0 ]; then break; fi; sleep 0.5; done;
91+
sabre cr --create product --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://grid-sawtooth-rest-api:8008 --wait 30
92+
sabre upload --filename product.yaml --key /grid-shared/my_key --url http://grid-sawtooth-rest-api:8008 --wait 30
93+
sabre ns --create cad11d --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://grid-sawtooth-rest-api:8008 --wait 30
94+
sabre ns --create 621dee01 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://grid-sawtooth-rest-api:8008 --wait 30
95+
sabre ns --create 621dee02 --key /grid-shared/my_key --owner $$(cat /grid-shared/my_key.pub) --url http://grid-sawtooth-rest-api:8008 --wait 30
96+
sabre perm cad11d product --key /grid-shared/my_key --read --write --url http://grid-sawtooth-rest-api:8008 --wait 30
97+
sabre perm 621dee01 product --key /grid-shared/my_key --read --url http://grid-sawtooth-rest-api:8008 --wait 30
98+
sabre perm 621dee02 product --key /grid-shared/my_key --read --write --url http://grid-sawtooth-rest-api:8008 --wait 30
99+
echo '---------========= product contract is loaded =========---------'
100+
"
79101
80102
validator:
81103
image: hyperledger/sawtooth-validator:1.1

0 commit comments

Comments
 (0)