Refactor schema contract Dockerfile
@@ -53,25 +53,34 @@ RUN curl -OLsS https://github.com/google/protobuf/releases/download/v3.7.1/proto
&& unzip -o protoc-3.7.1-linux-x86_64.zip -d /usr/local \
&& rm protoc-3.7.1-linux-x86_64.zip
-COPY ./sdk /sdk
+RUN mkdir /build
+# Copy grid sdk dependency
+COPY sdk/ /build/sdk/
+
+# Create empty cargo project
+WORKDIR /build
RUN mkdir contracts \
&& USER=root cargo new --bin contracts/schema
-WORKDIR /contracts/schema
-# Build TP with dummy source in order to cache dependencies in Docker image.
-COPY ./contracts/schema/Cargo.toml ./Cargo.toml
-RUN cargo build --release
+# Copy over Cargo.toml file
+COPY contracts/schema/Cargo.toml /build/contracts/schema/Cargo.toml
-COPY contracts/schema/Cargo.toml contracts/schema/Cargo.lock* ./
-RUN cargo build
+# Do a release build to cache dependencies
+WORKDIR /build/contracts/schema
+RUN cargo build --release
+# Remove the auto-generated .rs files and the built files
RUN rm src/*.rs
-COPY ./contracts/schema/src ./src
+RUN rm target/release/grid-schema-tp* target/release/deps/grid_schema*
+
+# Copy over source files
+COPY contracts/schema/src /build/contracts/schema/src
-RUN rm ./target/release/grid-schema-tp* ./target/release/deps/grid_schema*
+# Build the contract
RUN cargo build --target wasm32-unknown-unknown --release
-COPY ./contracts/schema/schema.yaml ./schema.yaml
+# Copy the contract definition
+COPY contracts/schema/schema.yaml /build/contracts/schema/schema.yaml
ENTRYPOINT []
