Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jasl committed Apr 3, 2023
1 parent 94b0ab7 commit 66963f8
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 45 deletions.
80 changes: 44 additions & 36 deletions build_and_push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@
# frozen_string_literal: true

BUILD_ONLY = false
GIT_TAG = "v0.1.21-dev.1"
GIT_TAG = "main"

COMMON_TAG = GIT_TAG
COMMON_TAG = "v0.1.23-dev.4" # GIT_TAG

KHALA_NODE_BIN_DOCKER_REPO = "khala-node-bin"
KHALA_NODE_BIN_DOCKER_TAG = COMMON_TAG
KHALA_NODE_BIN_GIT_TAG = GIT_TAG
KHALA_NODE_BIN_GIT_TAG = "polkadot-v0.9.40" # GIT_TAG

PHALA_NODE_BIN_DOCKER_REPO = "phala-node-bin"
PHALA_NODE_BIN_DOCKER_TAG = COMMON_TAG
PHALA_NODE_BIN_GIT_TAG = GIT_TAG
PHALA_NODE_BIN_GIT_TAG = "polkadot-v0.9.40" # GIT_TAG

KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO = "khala-node"
KHALA_NODE_WITH_LAUNCHER_DOCKER_TAG = PHALA_NODE_BIN_DOCKER_TAG
# Old one
KHALA_NODE_DOCKER_REPO = "khala-node"
KHALA_NODE_DOCKER_TAG = KHALA_NODE_BIN_DOCKER_TAG

PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO = "phala-node"
KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO = "khala-node-with-launcher"
KHALA_NODE_WITH_LAUNCHER_DOCKER_TAG = KHALA_NODE_BIN_DOCKER_TAG

PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO = "phala-node-with-launcher"
PHALA_NODE_WITH_LAUNCHER_DOCKER_TAG = PHALA_NODE_BIN_DOCKER_TAG

REGISTRIES = [
"jasl123",
# "phalanetwork",
# "swr.cn-east-3.myhuaweicloud.com/phala",
# "docker.pkg.github.com/phala-network/khala-docker"
# "ghcr.io/phala-network/khala-node"
]

require "open3"
Expand All @@ -48,7 +52,9 @@ def run(cmd)
"docker build --build-arg PHALA_GIT_TAG=#{KHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} .",
"docker build --build-arg PHALA_GIT_TAG=#{KHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{KHALA_NODE_BIN_DOCKER_REPO} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} -f khala-node-with-launcher.Dockerfile -t #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} -f khala-node-with-launcher.Dockerfile -t #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO} ."
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} -f khala-node-with-launcher.Dockerfile -t #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} -f khala-node.Dockerfile -t #{registry}/#{KHALA_NODE_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG} -f khala-node.Dockerfile -t #{registry}/#{KHALA_NODE_DOCKER_REPO} ."
].each do |cmd|
puts cmd
run cmd
Expand All @@ -62,38 +68,40 @@ def run(cmd)
"docker push #{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}:#{KHALA_NODE_BIN_DOCKER_TAG}",
"docker push #{registry}/#{KHALA_NODE_BIN_DOCKER_REPO}",
"docker push #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{KHALA_NODE_WITH_LAUNCHER_DOCKER_TAG}",
"docker push #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}"
"docker push #{registry}/#{KHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}",
"docker push #{registry}/#{KHALA_NODE_DOCKER_REPO}:#{KHALA_NODE_DOCKER_TAG}",
"docker push #{registry}/#{KHALA_NODE_DOCKER_REPO}"
].each do |cmd|
puts cmd
run cmd
end
end
end

# # Build Phala-Node
# REGISTRIES.each do |registry|
# [
# "docker build --build-arg PHALA_GIT_TAG=#{PHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} .",
# "docker build --build-arg PHALA_GIT_TAG=#{PHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO} .",
# "docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} -f phala-node-with-launcher.Dockerfile -t #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} .",
# "docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} -f phala-node-with-launcher.Dockerfile -t #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO} ."
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# Build Phala-Node
REGISTRIES.each do |registry|
[
"docker build --build-arg PHALA_GIT_TAG=#{PHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} .",
"docker build --build-arg PHALA_GIT_TAG=#{PHALA_NODE_BIN_GIT_TAG} -f node-bin.Dockerfile -t #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} -f phala-node-with-launcher.Dockerfile -t #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} .",
"docker build --build-arg NODE_BIN_IMAGE=#{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG} -f phala-node-with-launcher.Dockerfile -t #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO} ."
].each do |cmd|
puts cmd
run cmd
end
end

# unless BUILD_ONLY
# # Push Phala-Node
# REGISTRIES.each do |registry|
# [
# "docker push #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG}",
# "docker push #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}",
# "docker push #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{PHALA_NODE_WITH_LAUNCHER_DOCKER_TAG}",
# "docker push #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}"
# ].each do |cmd|
# puts cmd
# run cmd
# end
# end
# end
unless BUILD_ONLY
# Push Phala-Node
REGISTRIES.each do |registry|
[
"docker push #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}:#{PHALA_NODE_BIN_DOCKER_TAG}",
"docker push #{registry}/#{PHALA_NODE_BIN_DOCKER_REPO}",
"docker push #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}:#{PHALA_NODE_WITH_LAUNCHER_DOCKER_TAG}",
"docker push #{registry}/#{PHALA_NODE_WITH_LAUNCHER_DOCKER_REPO}"
].each do |cmd|
puts cmd
run cmd
end
end
end
75 changes: 75 additions & 0 deletions dockerfile.d/start_node_new.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

DATA_PATH="$HOME/data"

NODE_NAME="${NODE_NAME:-"khala-node"}"
NODE_ROLE="${NODE_ROLE:-""}"

PARACHAIN_PORT="${PARACHAIN_PORT:-"30333"}"
RELAYCHAIN_PORT="${RELAYCHAIN_PORT:-"30334"}"

PARACHAIN_DB="${PARACHAIN_DB:-"paritydb"}"
RELAYCHAIN_DB="${RELAYCHAIN_DB:-"paritydb"}"

PARACHAIN="${PARACHAIN:-"phala"}"
RELAYCHAIN="${RELAYCHAIN:-"polkadot"}"

case ${NODE_ROLE} in
"")
echo "You must set NODE_ROLE env"
echo "accept values (case sensitive): <Empty> | FULL | ARCHIVE | COLLATOR | MINER"
exit 1
;;
"FULL")
PARACHAIN_ROLE_ARGS=""
RELAYCHAIN_ROLE_ARGS=""
;;
"ARCHIVE")
PARACHAIN_ROLE_ARGS="--blocks-pruning archive-canonical --state-pruning archive-canonical --rpc-external"
RELAYCHAIN_ROLE_ARGS=""
;;
"COLLATOR")
PARACHAIN_ROLE_ARGS="--collator --rpc-external --rpc-methods unsafe"
RELAYCHAIN_ROLE_ARGS=""
;;
"MINER")
PARACHAIN_ROLE_ARGS="--blocks-pruning archive-canonical --state-pruning archive-canonical --rpc-external --rpc-methods unsafe"
RELAYCHAIN_ROLE_ARGS="--blocks-pruning archive-canonical --state-pruning archive-canonical --rpc-external --rpc-methods unsafe"
;;
*)
echo "Unknown NODE_ROLE ${NODE_ROLE}"
echo "accept values (case sensitive): <Empty> | FULL | ARCHIVE | COLLATOR | MINER"
exit 1
;;
esac

echo "Starting Khala node as role '${NODE_ROLE}' with extra parachain args '${PARACHAIN_EXTRA_ARGS}' extra relaychain args '${RELAYCHAIN_EXTRA_ARGS}'"

/usr/local/bin/khala-node \
--chain $PARACHAIN \
--base-path $DATA_PATH \
--database $PARACHAIN_DB \
--name $NODE_NAME \
--port $PARACHAIN_PORT \
--prometheus-port 9615 \
--rpc-port 9933 \
--ws-port 9944 \
--prometheus-external \
--ws-external \
--rpc-cors all \
--no-hardware-benchmarks \
$PARACHAIN_ROLE_ARGS \
$PARACHAIN_EXTRA_ARGS \
-- \
--chain $RELAYCHAIN \
--database $RELAYCHAIN_DB \
--port $RELAYCHAIN_PORT \
--prometheus-port 9616 \
--rpc-port 9934 \
--ws-port 9945 \
--prometheus-external \
--ws-external \
--rpc-cors all \
--no-hardware-benchmarks \
$RELAYCHAIN_ROLE_ARGS \
$RELAYCHAIN_EXTRA_ARGS
6 changes: 3 additions & 3 deletions khala-node-with-launcher.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM $NODE_BIN_IMAGE

WORKDIR /root

ADD dockerfile.d/start_node.sh ./start_node.sh
ADD dockerfile.d/start_node_new.sh ./start_node.sh

ENV RUST_LOG="info"
ENV NODE_NAME="khala-node"
Expand All @@ -12,8 +12,8 @@ ENV NODE_ROLE=""
ENV PARACHAIN="khala"
ENV RELAYCHAIN="kusama"

ENV PARACHAIN_DB="rocksdb"
ENV RELAYCHAIN_DB="rocksdb"
ENV PARACHAIN_DB="paritydb"
ENV RELAYCHAIN_DB="paritydb"

ENV PARACHAIN_EXTRA_ARGS=""
ENV RELAYCHAIN_EXTRA_ARGS=""
Expand Down
32 changes: 32 additions & 0 deletions khala-node.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
ARG NODE_BIN_IMAGE=""
FROM $NODE_BIN_IMAGE

WORKDIR /root

ADD dockerfile.d/start_node.sh ./start_node.sh

ENV RUST_LOG="info"
ENV NODE_NAME="khala-node"
ENV NODE_ROLE=""

ENV PARACHAIN="khala"
ENV RELAYCHAIN="kusama"

ENV PARACHAIN_DB="rocksdb"
ENV RELAYCHAIN_DB="rocksdb"

ENV PARACHAIN_EXTRA_ARGS=""
ENV RELAYCHAIN_EXTRA_ARGS=""

EXPOSE 9615
EXPOSE 9616
EXPOSE 9933
EXPOSE 9934
EXPOSE 9944
EXPOSE 9945
EXPOSE 30333
EXPOSE 30334

ENTRYPOINT ["/usr/bin/tini", "--"]

CMD ["/bin/bash", "./start_node.sh"]
2 changes: 1 addition & 1 deletion node-bin.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:22.04 AS builder

ARG RUST_TOOLCHAIN='nightly-2022-10-25'
ARG RUST_TOOLCHAIN='nightly-2023-02-03'
ARG CARGO_PROFILE='production'
ARG PHALA_GIT_REPO='https://github.com/Phala-Network/khala-parachain.git'
ARG PHALA_GIT_TAG='main'
Expand Down
6 changes: 3 additions & 3 deletions phala-node-with-launcher.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM $NODE_BIN_IMAGE

WORKDIR /root

ADD dockerfile.d/start_node.sh ./start_node.sh
ADD dockerfile.d/start_node_new.sh ./start_node.sh

ENV RUST_LOG="info"
ENV NODE_NAME="phala-node"
Expand All @@ -12,8 +12,8 @@ ENV NODE_ROLE=""
ENV PARACHAIN="phala"
ENV RELAYCHAIN="polkadot"

ENV PARACHAIN_DB="rocksdb"
ENV RELAYCHAIN_DB="rocksdb"
ENV PARACHAIN_DB="paritydb"
ENV RELAYCHAIN_DB="paritydb"

ENV PARACHAIN_EXTRA_ARGS=""
ENV RELAYCHAIN_EXTRA_ARGS=""
Expand Down
4 changes: 2 additions & 2 deletions thala-dev-node.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM ubuntu:20.04 AS builder

ARG DEBIAN_FRONTEND='noninteractive'
ARG RUST_TOOLCHAIN='nightly-2022-07-11'
ARG RUST_TOOLCHAIN='nightly-2023-02-03'
ARG PHALA_GIT_REPO='https://github.com/Phala-Network/khala-parachain.git'
ARG PHALA_GIT_TAG='main'
ARG POLKADOT_VERSION="v0.9.26"
ARG POLKADOT_VERSION="v0.9.40"

WORKDIR /root

Expand Down

0 comments on commit 66963f8

Please sign in to comment.