Browse Source

reorganize scripts and docker files

Mokhtar Naamani 5 years ago
parent
commit
bc0b5115ff

+ 1 - 1
.dockerignore

@@ -1 +1 @@
-target/
+**target*

+ 0 - 20
build-with-docker.sh

@@ -1,20 +0,0 @@
-#!/bin/bash
-
-# Build the toolchain image - contains only the compiler environmet for building runtime
-# This is then pushed to docker hub: https://cloud.docker.com/repository/docker/mokhtargz/wasm-toolchain/general
-# docker build --tag mokhtargz/wasm-toolchain --file ./wasm_dockerfile .
-
-# Build the runtime in a new image
-docker build --tag runtime-build --file ./runtime_dockerfile .
-
-# Create a non running container from the runtime build image
-docker create --name runtime-container runtime-build
-# Copy the compiled wasm blob from the docker container to our host
-docker cp runtime-container:/runtime/target/release/wbuild/joystream-node-runtime/joystream_node_runtime.compact.wasm joystream_runtime.wasm
-docker rm runtime-container
-
-# compute blake2_256 hash of the wasm blob - this should match the hash computed when the runtime file is
-# used to create a runtime upgrade proposal.
-# osx with: brew install b2sum; b2sum -b blake2b -l 256 joystream_runtime.wasm
-# ubuntu 17.0+ with: apt-get install coreutils; b2sum -l 256 joystream_runtime.wasm
-b2sum -l 256 joystream_runtime.wasm

+ 2 - 1
node/Dockerfile → devops/dockerfiles/node-and-runtime/Dockerfile

@@ -1,5 +1,5 @@
 FROM joystream/rust-builder AS builder
-LABEL description="compiles and caches dependencies, artifacts and node"
+LABEL description="Compiles all workspace artifacts"
 WORKDIR /joystream
 COPY . /joystream
 
@@ -9,6 +9,7 @@ FROM debian:stretch
 LABEL description="Joystream node"
 WORKDIR /joystream
 COPY --from=builder /joystream/target/release/joystream-node /joystream/node
+COPY --from=builder /joystream/target/release/wbuild/joystream-node-runtime/joystream_node_runtime.compact.wasm /joystream/runtime.compact.wasm
 
 # confirm it works
 RUN /joystream/node --version

+ 0 - 0
node/Dockerfile_experimental → devops/dockerfiles/node-and-runtime/Dockerfile_experimental


+ 8 - 0
devops/dockerfiles/rust-builder/Dockerfile

@@ -0,0 +1,8 @@
+FROM liuchong/rustup:1.41.1 AS builder
+LABEL description="Rust and WASM build environment for joystream and substrate"
+
+WORKDIR /setup
+COPY setup.sh /setup
+ENV TERM=xterm
+
+RUN ./setup.sh

+ 0 - 1
node/.dockerignore

@@ -1 +0,0 @@
-target/

+ 1 - 1
node/README.md

@@ -11,7 +11,7 @@ For setting up a full node and valiador review the [advanced guide from the help
 
 ##  Binary releases
 
-The latest pre build binaries can be downloads from the [releases](https://github.com/Joystream/substrate-node-joystream/releases) page.
+The latest pre build binaries can be downloads from the [releases](https://github.com/Joystream/substrate-runtime-joystream/releases) page.
 
 
 ## Building from source

+ 0 - 5
node/build-clean-start.sh

@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-cargo build
-cargo run -- purge-chain --dev
-cargo run -- --dev

+ 0 - 13
node/raspberry-cross-build.sh

@@ -1,13 +0,0 @@
-#!/bin/sh
-
-### Cross build for Raspberry Pi - using docker ###
-docker pull joystream/rust-raspberry
-
-docker run \
-    --volume ${PWD}/:/home/cross/project \
-    --volume ${HOME}/.cargo/registry:/home/cross/.cargo/registry \
-    joystream/rust-raspberry \
-    build --release
-
-# output will be in project folder:
-# target/arm-unknown-linux-gnueabihf/joystream-node

+ 0 - 19
node/setup.sh

@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-# Install OS dependencies
-curl https://getsubstrate.io -sSf | bash -s -- --fast
-
-echo "*** Initialising WASM build environment"
-
-if [ -z $CI_PROJECT_NAME ] ; then
-   rustup update nightly
-   rustup update stable
-fi
-
-rustup target add wasm32-unknown-unknown --toolchain nightly
-
-# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
-command -v wasm-gc || \
-	cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force

+ 3 - 0
CHANGELOG.md → runtime/CHANGELOG.md

@@ -1,3 +1,6 @@
+### Version 6.9.1
+...
+
 ### Version 6.8.0 (Rome release) - March 9th 2020
 - New versioned and permissioned content mangement system that powers a new media experience.
 - Content Working Group - introduces staked content curator roles to maintain quality of content and ensure that is meets the platform's terms of service.

+ 0 - 0
README.md → runtime/README.md


+ 0 - 0
banner_new.svg → runtime/banner_new.svg


+ 0 - 12
runtime_dockerfile

@@ -1,12 +0,0 @@
-# use toolchain image from: https://cloud.docker.com/repository/docker/mokhtargz/wasm-toolchain/general
-FROM mokhtargz/wasm-toolchain
-LABEL description="Joystream substrate runtime build"
-
-WORKDIR /runtime
-COPY . /runtime
-ENV TERM=xterm
-
-RUN rustup show
-
-# Build the runtime
-RUN cargo test && cargo build --release

+ 7 - 0
scripts/build-joystream-node-docker-image.sh

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+# Build the node and runtime image
+docker build --tag joystream/node \
+    --file ./devops/dockerfiles/node-and-runtime/Dockerfile \
+    .
+

+ 7 - 0
scripts/build-rust-builder-docker-image.sh

@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+# Build the joystream/rust-builder image
+docker build --tag joystream/rust-builder \
+    --file ./devops/dockerfiles/rust-builder/Dockerfile \
+    .
+

+ 16 - 0
scripts/compute-runtime-blob-hash.sh

@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# Create a non running container from joystream/node
+docker create --name temp-container-joystream-node joystream/node
+
+# Copy the compiled wasm blob from the docker container to our host
+docker cp temp-container-joystream-node:/joystream/runtime.compact.wasm joystream_runtime.wasm
+docker rm temp-container-joystream-node
+
+# compute blake2_256 hash of the wasm blob - this should match the hash computed when the runtime file is
+# used to create a runtime upgrade proposal.
+# osx with: brew install b2sum; b2sum -b blake2b -l 256 joystream_runtime.wasm
+# ubuntu 17.0+ with: apt-get install coreutils; b2sum -l 256 joystream_runtime.wasm
+# TODO: add install of b2sum to setup.sh
+b2sum -l 256 joystream_runtime.wasm
+rm joystream_runtime.wasm

+ 19 - 0
scripts/raspberry-cross-build.sh

@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# Run this script from the crago workspace root
+
+# Cross compiles release build of joystream-node
+# for Raspberry Pi - using docker
+
+# joystream/rust-raspberry image was built from:
+# https://github.com/mnaamani/rust-on-raspberry-docker/commit/8536508b743d55c8573043c4082c62da3b4fd3e2
+docker pull joystream/rust-raspberry
+
+docker run \
+    --volume ${PWD}/:/home/cross/project \
+    --volume ${HOME}/.cargo/registry:/home/cross/.cargo/registry \
+    joystream/rust-raspberry \
+    build --release -p joystream-node
+
+# artifacts will be relative to the working directory:
+# target/arm-unknown-linux-gnueabihf/joystream-node

+ 3 - 0
scripts/run-dev-chain-as-container.sh

@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+docker run -p 9944:9944 joystream/node --dev --ws-external

+ 10 - 0
scripts/run-dev-chain.sh

@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+# Build release binary
+cargo build --release -p joystream-node
+
+# Purge existing local chain
+yes | cargo run --release -p joystream-node -- purge-chain --dev
+
+# Run local development chain
+cargo run --release -p joystream-node -- --dev

+ 5 - 2
setup.sh

@@ -3,9 +3,12 @@
 set -e
 
 # If OS is supported will install:
-#  - build tools and any other dependencies required for rust
+#  - build tools and any other dependencies required for rust and substrate
 #  - rustup - rust insaller
 #  - rust compiler and toolchains
 #  - skips installing substrate and subkey
-curl https://getsubstrate.io -sSf | bash -s -- --fast
+curl https://getsubstrate.io -sSf | bash -s -- --fast \
+    && rustup component add rustfmt
 
+# TODO: Install additional tools...
+# - b2sum

+ 0 - 10
wasm_dockerfile

@@ -1,10 +0,0 @@
-FROM liuchong/rustup:1.41.1 AS builder
-LABEL description="Joystream wasm toolchain image"
-
-ENV TERM=xterm
-
-WORKDIR /setup
-COPY ./setup.sh /setup/
-ENV TERM=xterm
-
-RUN ./setup.sh