Skip to content

Commit

Permalink
Renaming binary + docker (#223)
Browse files Browse the repository at this point in the history
* Initial draft for renaming binary + docker

* format rust code

* Faster tests

* Better fix for ts test speed

* Fix parachain docker image

* fix parachain docker name

* Better entrypoint format in docker

* Update docker/moonbase-parachain.Dockerfile

Co-authored-by: Joshy Orndorff <[email protected]>

* revert test filename check

* Testing smaller docker image

Co-authored-by: Joshy Orndorff <[email protected]>
  • Loading branch information
crystalin and JoshOrndorff authored Feb 9, 2021
1 parent 5308f49 commit 4253817
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 81 deletions.
135 changes: 97 additions & 38 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
- id: get-rust-versions
run: |
echo "::set-output name=rustc::$(rustc --version)"
- name: Build Parachain Node
- name: Build Node
run: cargo build --release --verbose --all
# We determine whether there are unmodified Cargo.lock files by:
# 1. Asking git for a list of all modified files
Expand All @@ -202,13 +202,13 @@ jobs:
npm run test;
- name: Save parachain binary
run: |
mkdir -p build/alphanet
cp target/release/moonbase-alphanet build/alphanet/moonbase-alphanet;
- name: Upload moonbase-alphanet node
mkdir -p build
cp target/release/moonbeam build/moonbeam;
- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
name: moonbeam
path: build

####### Prepare and Deploy Docker images #######

Expand All @@ -221,17 +221,17 @@ jobs:
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
name: moonbeam
path: build
- name: Generate specs
run: |
chmod uog+x build/alphanet/moonbase-alphanet
PARACHAIN_BINARY=build/alphanet/moonbase-alphanet scripts/generate-parachain-specs.sh
chmod uog+x build/moonbeam
PARACHAIN_BINARY=build/moonbeam scripts/generate-parachain-specs.sh
- name: Upload parachain specs
uses: actions/upload-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
name: moonbeam
path: build

docker-parachain:
runs-on: self-hosted
Expand All @@ -242,12 +242,12 @@ jobs:
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
name: moonbeam
path: build
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=purestake/moonbase-parachain-testnet
DOCKER_IMAGE=purestake/moonbase-parachain
VERSION=noop
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
Expand Down Expand Up @@ -290,7 +290,78 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/moonbase-alphanet.Dockerfile
file: ./docker/moonbase-parachain.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}
docker-moonbeam:
runs-on: self-hosted
needs: ["build", "generate-parachain-specs"]
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: moonbeam
path: build
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=purestake/moonbeam
VERSION=noop
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
elif [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=edge
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
version: latest
driver-opts: |
image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push moonbeam
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./docker/moonbeam.Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
Expand Down Expand Up @@ -339,7 +410,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Moonbase Alphanet ${{ github.ref }}
release_name: Moonbase ${{ github.ref }}
body: "TBD"
draft: true

Expand All @@ -351,49 +422,37 @@ jobs:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
runtime: ["moonbase-alphanet"]
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: moonbase-alphanet
path: build/alphanet
name: moonbeam
path: build
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- name: Get runtime version
id: get-runtime-ver
run: |
runtime_ver="$(ruby -e 'require "./scripts/github/lib.rb"; puts get_runtime("parachain.rs")')"
runtime_ver="$(ruby -e 'require "./scripts/github/lib.rb"; puts get_runtime("lib.rs")')"
echo "::set-output name=runtime_ver::$runtime_ver"
- name: Upload ${{ matrix.runtime }} wasm
- name: Upload wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/alphanet/${{ matrix.runtime }}-runtime.wasm
asset_name: ${{ matrix.runtime }}-runtime-v${{ steps.get-runtime-ver.outputs.runtime_ver }}.wasm
asset_path: build/runtime.wasm
asset_name: runtime-v${{ steps.get-runtime-ver.outputs.runtime_ver }}.wasm
asset_content_type: application/wasm
- name: Upload ${{ matrix.runtime }} node
- name: Upload binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/alphanet/${{ matrix.runtime }}
asset_name: ${{ matrix.runtime }}
asset_path: build/moonbeam
asset_name: moonbeam
asset_content_type: application/octet-stream
- name: Upload ${{ matrix.runtime }} genesis
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }}
asset_path: build/alphanet/${{ matrix.runtime }}-genesis.txt
asset_name: ${{ matrix.runtime }}-genesis.txt
asset_content_type: text/plain
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

FROM phusion/baseimage:0.11
LABEL maintainer "[email protected]"
LABEL description="this is the parachain node running Moonbase Alphanet"
LABEL description="Moonbeam network node. Supports Alphanet. Will support Moonriver and Moonbeam mainnet."
ARG PROFILE=release

RUN mv /usr/share/ca* /tmp && \
rm -rf /usr/share/* && \
mv /tmp/ca-certificates /usr/share/ && \
rm -rf /usr/lib/python* && \
useradd -m -u 1000 -U -s /bin/sh -d /moonbase-alphanet moonbeam && \
mkdir -p /moonbase-alphanet/.local/share/moonbase-alphanet && \
chown -R moonbeam:moonbeam /moonbase-alphanet && \
ln -s /moonbase-alphanet/.local/share/moonbase-alphanet /data && \
useradd -m -u 1000 -U -s /bin/sh -d /moonbase-parachain moonbeam && \
mkdir -p /moonbase-parachain/.local/share/moonbase-parachain && \
chown -R moonbeam:moonbeam /moonbase-parachain && \
ln -s /moonbase-parachain/.local/share/moonbase-parachain /data && \
rm -rf /usr/bin /usr/sbin

USER moonbeam

COPY --chown=moonbeam build/alphanet /moonbase-alphanet
RUN chmod uog+x /moonbase-alphanet/moonbase-alphanet
COPY --chown=moonbeam build /moonbase-parachain
RUN chmod uog+x /moonbase-parachain/moonbeam

# 30333 for parachain p2p
# 30334 for relaychain p2p
Expand All @@ -31,6 +31,4 @@ EXPOSE 30333 30334 9933 9944 9615

VOLUME ["/data"]

CMD ["/moonbase-alphanet/moonbase-alphanet", \
"--chain", "alphanet"\
]
CMD ["/moonbase-parachain/moonbeam"]
27 changes: 27 additions & 0 deletions docker/moonbeam.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Node for Moonbase Alphanet.
#
# Requires to run from repository root and to copy the binary in the build folder (part of the release workflow)

FROM debian:buster-slim
LABEL maintainer "[email protected]"
LABEL description="Binary for Moonbeam Collator"

RUN useradd -m -u 1000 -U -s /bin/sh -d /moonbeam moonbeam && \
mkdir -p /moonbeam/.local/share && \
mkdir /data && \
chown -R moonbeam:moonbeam /data && \
ln -s /data /moonbeam/.local/share/moonbeam && \
rm -rf /usr/bin /usr/sbin

USER moonbeam

# 30333 for parachain p2p
# 30334 for relaychain p2p
# 9933 for RPC call
# 9944 for Websocket
# 9615 for Prometheus (metrics)
EXPOSE 30333 30334 9933 9944 9615

VOLUME ["/data"]

ENTRYPOINT ["/moonbeam/moonbeam"]
1 change: 1 addition & 0 deletions moonbeam-types-bundle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export const moonbeamDefinitions = {

export const typesBundle = {
spec: {
moonbeam: moonbeamDefinitions,
"moonbase-alphanet": moonbeamDefinitions,
moonbeamDefinitions,
"moonbeam-standalone": moonbeamDefinitions,
Expand Down
4 changes: 2 additions & 2 deletions moonbeam-types-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"url": "git+https://github.com/PureStake/moonbeam.git"
},
"dependencies": {
"@polkadot/api": "^3.6.4",
"@polkadot/types": "^3.6.4",
"@polkadot/api": "^3.7.1",
"@polkadot/types": "^3.7.1",
"typescript": "^4.1.3"
}
}
6 changes: 3 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'moonbase-alphanet'
description = 'Moonbase Collator'
name = 'moonbeam'
description = 'Moonbeam Collator'
homepage = 'https://moonbeam.network'
license = 'GPL-3.0-only'
version = '0.1.0'
Expand All @@ -9,7 +9,7 @@ build = 'build.rs'
edition = '2018'

[[bin]]
name = 'moonbase-alphanet'
name = 'moonbeam'
path = 'src/main.rs'

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pub mod opaque {

/// This runtime version.
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("moonbase-alphanet"),
impl_name: create_runtime_str!("moonbase-alphanet"),
spec_name: create_runtime_str!("moonbeam"),
impl_name: create_runtime_str!("moonbeam"),
authoring_version: 3,
spec_version: 19,
impl_version: 1,
Expand Down
13 changes: 2 additions & 11 deletions scripts/_init_var.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@ fi

mkdir -p $PARACHAIN_BUILD_FOLDER


if [ -z "$STANDALONE_BINARY" ]; then
STANDALONE_BINARY="node/standalone/target/release/moonbase-standalone"
fi

if [ -z "$PARACHAIN_BINARY" ]; then
PARACHAIN_BINARY="target/release/moonbase-alphanet"
fi

if [ -z "$STANDALONE_SPEC_TMP" ]; then
STANDALONE_SPEC_TMP="/tmp/moonbase-standalone-specs-tmp.json"
if [ -z "$MOONBEAM_BINARY" ]; then
MOONBEAM_BINARY="target/release/moonbeam"
fi

if [ -z "$ALPHANET_SPEC_TEMPLATE" ]; then
Expand Down
8 changes: 4 additions & 4 deletions scripts/generate-parachain-specs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source scripts/_init_var.sh

echo "=================== Alphanet ==================="
$PARACHAIN_BINARY build-spec \
$MOONBEAM_BINARY build-spec \
--disable-default-bootnode \
| grep '\"code\"' \
| head -n1 > $ALPHANET_SPEC_TMP
Expand All @@ -13,19 +13,19 @@ sed -e "/\"<runtime_code>\"/{r $ALPHANET_SPEC_TMP" -e 'd;}' $ALPHANET_SPEC_TEMP
> $ALPHANET_SPEC_PLAIN
echo $ALPHANET_SPEC_PLAIN generated

$PARACHAIN_BINARY build-spec \
$MOONBEAM_BINARY build-spec \
--disable-default-bootnode \
--raw \
--chain $ALPHANET_SPEC_PLAIN \
> $ALPHANET_SPEC_RAW
echo $ALPHANET_SPEC_RAW generated

$PARACHAIN_BINARY export-genesis-wasm \
$MOONBEAM_BINARY export-genesis-wasm \
--chain $ALPHANET_SPEC_RAW \
> $PARACHAIN_WASM;
echo $PARACHAIN_WASM generated

$PARACHAIN_BINARY export-genesis-state \
$MOONBEAM_BINARY export-genesis-state \
--parachain-id $PARACHAIN_ID \
--chain $ALPHANET_SPEC_RAW \
> $PARACHAIN_GENESIS;
Expand Down
Loading

0 comments on commit 4253817

Please sign in to comment.