@@ -17,18 +17,19 @@ FROM ubuntu:bionic as grid-pike-builder
17
17
RUN apt-get update \
18
18
&& apt-get install gnupg -y
19
19
20
+ # Install base dependencies
20
21
RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \
21
22
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
22
23
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
23
24
&& apt-get update \
24
25
&& apt-get install -y -q \
25
- curl \
26
- gcc \
27
- libssl-dev \
28
- libzmq3-dev \
29
- pkg-config \
30
- sabre-cli \
31
- unzip \
26
+ curl \
27
+ gcc \
28
+ libssl-dev \
29
+ libzmq3-dev \
30
+ pkg-config \
31
+ sabre-cli \
32
+ unzip \
32
33
&& apt-get clean \
33
34
&& rm -rf /var/lib/apt/lists/*
34
35
@@ -47,25 +48,34 @@ RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/proto
47
48
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
48
49
&& rm protoc-3.7.1-linux-x86_64.zip
49
50
50
- COPY ./sdk /sdk
51
+ RUN mkdir /build
51
52
53
+ # Copy grid sdk dependency
54
+ COPY sdk/ /build/sdk/
55
+
56
+ # Create empty cargo project
57
+ WORKDIR /build
52
58
RUN mkdir contracts \
53
59
&& USER=root cargo new --bin contracts/pike
54
- WORKDIR /contracts/pike
55
60
56
- # Build TP with dummy source in order to cache dependencies in Docker image.
57
- COPY ./contracts/pike/Cargo.toml ./Cargo.toml
58
- RUN cargo build --release
61
+ # Copy over Cargo.toml file
62
+ COPY contracts/pike/Cargo.toml /build/contracts/pike/Cargo.toml
59
63
60
- COPY contracts/pike/Cargo.toml contracts/pike/Cargo.lock* ./
61
- RUN cargo build
64
+ # Do a release build to cache dependencies
65
+ WORKDIR /build/contracts/pike
66
+ RUN cargo build --release
62
67
68
+ # Remove the auto-generated .rs files and the built files
63
69
RUN rm src/*.rs
64
- COPY ./contracts/pike/src ./src
70
+ RUN rm target/release/grid-pike-tp* target/release/deps/grid_pike*
71
+
72
+ # Copy over source files
73
+ COPY contracts/pike/src /build/contracts/pike/src
65
74
66
- RUN rm ./target/release/grid-pike-tp* ./target/release/deps/grid_pike*
75
+ # Build the contract
67
76
RUN cargo build --target wasm32-unknown-unknown --release
68
77
69
- COPY ./contracts/pike/pike.yaml ./pike.yaml
78
+ # Copy the contract definition
79
+ COPY contracts/pike/pike.yaml /build/contracts/pike/pike.yaml
70
80
71
81
ENTRYPOINT []
0 commit comments