|
| 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 [] |
0 commit comments