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

Commit 622fa66

Browse files
committed
Refactor pike contract Dockerfile
Signed-off-by: Ryan Beck-Buysse <[email protected]>
1 parent 1414dbb commit 622fa66

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

contracts/pike/Dockerfile

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@ FROM ubuntu:bionic as grid-pike-builder
1717
RUN apt-get update \
1818
&& apt-get install gnupg -y
1919

20+
# Install base dependencies
2021
RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/apt/sources.list \
2122
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
2223
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
2324
&& apt-get update \
2425
&& 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 \
3233
&& apt-get clean \
3334
&& rm -rf /var/lib/apt/lists/*
3435

@@ -47,25 +48,34 @@ RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/proto
4748
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
4849
&& rm protoc-3.7.1-linux-x86_64.zip
4950

50-
COPY ./sdk /sdk
51+
RUN mkdir /build
5152

53+
# Copy grid sdk dependency
54+
COPY sdk/ /build/sdk/
55+
56+
# Create empty cargo project
57+
WORKDIR /build
5258
RUN mkdir contracts \
5359
&& USER=root cargo new --bin contracts/pike
54-
WORKDIR /contracts/pike
5560

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
5963

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
6267

68+
# Remove the auto-generated .rs files and the built files
6369
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
6574

66-
RUN rm ./target/release/grid-pike-tp* ./target/release/deps/grid_pike*
75+
# Build the contract
6776
RUN cargo build --target wasm32-unknown-unknown --release
6877

69-
COPY ./contracts/pike/pike.yaml ./pike.yaml
78+
# Copy the contract definition
79+
COPY contracts/pike/pike.yaml /build/contracts/pike/pike.yaml
7080

7181
ENTRYPOINT []

0 commit comments

Comments
 (0)