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

Commit f908a4d

Browse files
authored
Merge pull request #110 from Cargill/rbuysse-dockerfile-cleanup
Dockerfile cleanup
2 parents 03051c4 + 79a9126 commit f908a4d

File tree

5 files changed

+192
-150
lines changed

5 files changed

+192
-150
lines changed

contracts/pike/Dockerfile

Lines changed: 31 additions & 21 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

@@ -42,30 +43,39 @@ RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
4243
RUN rustup update \
4344
&& rustup target add wasm32-unknown-unknown
4445

45-
# For Building Protobufs
46-
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip \
47-
&& unzip protoc-3.5.1-linux-x86_64.zip -d protoc3 \
48-
&& rm protoc-3.5.1-linux-x86_64.zip
46+
# Install protoc
47+
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
48+
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
49+
&& 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 []

contracts/product/Dockerfile

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/ap
2222
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
2323
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
2424
&& 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/*
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/*
4040

4141
ENV PATH=$PATH:/protoc3/bin:/root/.cargo/bin
4242

@@ -46,33 +46,41 @@ RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
4646
&& rustup-init -y
4747

4848
RUN rustup update \
49-
&& rustup default \
50-
&& rustup target add wasm32-unknown-unknown --toolchain stable
49+
&& rustup target add wasm32-unknown-unknown
5150

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
51+
# Install protoc
52+
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
53+
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
54+
&& rm protoc-3.7.1-linux-x86_64.zip
5655

57-
COPY ./sdk /sdk
56+
RUN mkdir /build
5857

58+
# Copy grid sdk dependency
59+
COPY sdk/ /build/sdk/
60+
61+
# Create empty cargo project
62+
WORKDIR /build
5963
RUN mkdir contracts \
6064
&& USER=root cargo new --bin contracts/product
61-
WORKDIR /contracts/product
6265

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+
# Copy over Cargo.toml file
67+
COPY contracts/product/Cargo.toml /build/contracts/product/Cargo.toml
6668

67-
COPY contracts/product/Cargo.toml contracts/product/Cargo.lock* ./
68-
RUN cargo build
69+
# Do a release build to cache dependencies
70+
WORKDIR /build/contracts/product
71+
RUN cargo build --release
6972

73+
# Remove the auto-generated .rs files and the built files
7074
RUN rm src/*.rs
71-
COPY ./contracts/product/src ./src
72-
7375
RUN rm ./target/release/grid-product-tp* ./target/release/deps/grid_product*
76+
77+
# Copy over source files
78+
COPY contracts/product/src /build/contracts/product/src
79+
80+
# Build the contract
7481
RUN cargo build --target wasm32-unknown-unknown --release
7582

76-
COPY ./contracts/product/product.yaml ./product.yaml
83+
# Copy the contract definition
84+
COPY contracts/product/product.yaml /build/contracts/product/product.yaml
7785

7886
ENTRYPOINT []

contracts/schema/Dockerfile

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/ap
2222
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
2323
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
2424
&& 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/*
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/*
4040

4141
ENV PATH=$PATH:/protoc3/bin:/root/.cargo/bin
4242

@@ -48,30 +48,39 @@ RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
4848
RUN rustup update \
4949
&& rustup target add wasm32-unknown-unknown
5050

51-
# For Building Protobufs
52-
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip \
53-
&& unzip -o protoc-3.5.1-linux-x86_64.zip -d /usr/local \
54-
&& rm protoc-3.5.1-linux-x86_64.zip
51+
# Install protoc
52+
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
53+
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
54+
&& rm protoc-3.7.1-linux-x86_64.zip
5555

56-
COPY ./sdk /sdk
56+
RUN mkdir /build
5757

58+
# Copy grid sdk dependency
59+
COPY sdk/ /build/sdk/
60+
61+
# Create empty cargo project
62+
WORKDIR /build
5863
RUN mkdir contracts \
5964
&& USER=root cargo new --bin contracts/schema
60-
WORKDIR /contracts/schema
6165

62-
# Build TP with dummy source in order to cache dependencies in Docker image.
63-
COPY ./contracts/schema/Cargo.toml ./Cargo.toml
64-
RUN cargo build --release
66+
# Copy over Cargo.toml file
67+
COPY contracts/schema/Cargo.toml /build/contracts/schema/Cargo.toml
6568

66-
COPY contracts/schema/Cargo.toml contracts/schema/Cargo.lock* ./
67-
RUN cargo build
69+
# Do a release build to cache dependencies
70+
WORKDIR /build/contracts/schema
71+
RUN cargo build --release
6872

73+
# Remove the auto-generated .rs files and the built files
6974
RUN rm src/*.rs
70-
COPY ./contracts/schema/src ./src
75+
RUN rm target/release/grid-schema-tp* target/release/deps/grid_schema*
76+
77+
# Copy over source files
78+
COPY contracts/schema/src /build/contracts/schema/src
7179

72-
RUN rm ./target/release/grid-schema-tp* ./target/release/deps/grid_schema*
80+
# Build the contract
7381
RUN cargo build --target wasm32-unknown-unknown --release
7482

75-
COPY ./contracts/schema/schema.yaml ./schema.yaml
83+
# Copy the contract definition
84+
COPY contracts/schema/schema.yaml /build/contracts/schema/schema.yaml
7685

7786
ENTRYPOINT []

contracts/track_and_trace/Dockerfile

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ RUN echo "deb http://repo.sawtooth.me/ubuntu/nightly bionic universe" >> /etc/ap
2222
&& (apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 44FC67F19B2466EA \
2323
|| apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 44FC67F19B2466EA) \
2424
&& 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/*
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/*
4040

4141
ENV PATH=$PATH:/protoc3/bin:/root/.cargo/bin
4242

@@ -48,30 +48,39 @@ RUN curl https://sh.rustup.rs -sSf > /usr/bin/rustup-init \
4848
RUN rustup update \
4949
&& rustup target add wasm32-unknown-unknown
5050

51-
# For Building Protobufs
52-
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip \
53-
&& unzip -o protoc-3.5.1-linux-x86_64.zip -d /usr/local \
54-
&& rm protoc-3.5.1-linux-x86_64.zip
51+
# Install protoc
52+
RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/protoc-3.7.1-linux-x86_64.zip \
53+
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
54+
&& rm protoc-3.7.1-linux-x86_64.zip
5555

56-
COPY ./sdk /sdk
56+
RUN mkdir /build
5757

58+
# Copy grid sdk dependency
59+
COPY sdk/ /build/sdk/
60+
61+
# Create empty cargo project
62+
WORKDIR /build
5863
RUN mkdir contracts \
5964
&& USER=root cargo new --bin contracts/track_and_trace
60-
WORKDIR /contracts/track_and_trace
6165

62-
# Build TP with dummy source in order to cache dependencies in Docker image.
63-
COPY ./contracts/track_and_trace/Cargo.toml ./Cargo.toml
64-
RUN cargo build --release
66+
# Copy over Cargo.toml file
67+
COPY contracts/track_and_trace/Cargo.toml /build/contracts/track_and_trace/Cargo.toml
6568

66-
COPY contracts/track_and_trace/Cargo.toml contracts/track_and_trace/Cargo.lock* ./
67-
RUN cargo build
69+
# Do a release build to cache dependencies
70+
WORKDIR /build/contracts/track_and_trace
71+
RUN cargo build --release
6872

73+
# Remove the auto-generated .rs files and the built files
6974
RUN rm src/*.rs
70-
COPY ./contracts/track_and_trace/src ./src
75+
RUN rm target/release/grid-track-and-trace-tp* target/release/deps/grid_track_and_trace*
76+
77+
# Copy over source files
78+
COPY contracts/track_and_trace/src /build/contracts/track_and_trace/src
7179

72-
RUN rm ./target/release/grid-track-and-trace-tp* ./target/release/deps/grid_track_and_trace*
80+
# Build the contract
7381
RUN cargo build --target wasm32-unknown-unknown --release
7482

75-
COPY ./contracts/track_and_trace/track_and_trace.yaml ./track_and_trace.yaml
83+
# Copy the contract definition
84+
COPY contracts/track_and_trace/track_and_trace.yaml /build/contracts/track_and_trace/track_and_trace.yaml
7685

7786
ENTRYPOINT []

0 commit comments

Comments
 (0)