Skip to content

Commit

Permalink
ci: move nodeonly to baedeker
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Sep 4, 2023
1 parent 140adbb commit a0b6705
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 369 deletions.
43 changes: 43 additions & 0 deletions .baedeker/node-only.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local
m = import 'baedeker-library/mixin/spec.libsonnet',
;

local relay = {
name: 'relay',
bin: 'bin/polkadot',
validatorIdAssignment: 'staking',
spec: {Genesis:{
chain: 'rococo-local',
modify:: m.genericRelay($),
}},
nodes: {
[name]: {
bin: $.bin,
wantedKeys: 'relay',
},
for name in ['alice', 'bob', 'charlie', 'dave', 'eve']
},
};

local unique = {
name: 'unique',
bin: 'bin/unique',
paraId: 1001,
spec: {Genesis:{
modify:: m.genericPara($),
}},
nodes: {
[name]: {
bin: $.bin,
wantedKeys: 'para',
},
for name in ['alice', 'bob']
},
};

relay + {
parachains: {
[para.name]: para,
for para in [unique]
},
}
67 changes: 0 additions & 67 deletions .docker/Dockerfile-parachain-node-only.j2

This file was deleted.

49 changes: 49 additions & 0 deletions .docker/Dockerfile-unique-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ===== Rust builder =====
FROM ubuntu:22.04 as rust-builder
LABEL maintainer="Unique.Network"

ENV CARGO_HOME="/cargo-home"
ENV PATH="/cargo-home/bin:$PATH"
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && \
apt-get install -y curl cmake pkg-config libssl-dev git clang llvm libudev-dev protobuf-compiler && \
apt-get clean && \
rm -r /var/lib/apt/lists/*

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain none

ARG RUST_TOOLCHAIN
RUN echo "Using Rust '$RUST_TOOLCHAIN'" && \
rustup toolchain install $RUST_TOOLCHAIN && \
rustup target add wasm32-unknown-unknown --toolchain ${RUST_TOOLCHAIN} && \
rustup default $RUST_TOOLCHAIN && \
rustup target list --installed && \
rustup show

RUN mkdir /unique_parachain
WORKDIR /unique_parachain

# ===== BUILD POLKADOT =====
FROM rust-builder as builder-polkadot-bin

WORKDIR /unique_parachain

ARG UNIQUE_VERSION
RUN git clone -b "$UNIQUE_VERSION" --depth 1 https://github.com/uniquenetwork/unique-chain.git

ARG RUNTIME_FEATURES
RUN --mount=type=cache,target=/cargo-home/registry \
--mount=type=cache,target=/cargo-home/git \
--mount=type=cache,target=/unique_parachain/polkadot/target \
cd unique-chain && \
CARGO_INCREMENTAL=0 cargo build --release --features="$RUNTIME_FEATURES" --locked && \
mv ./target/release/unique-collator /unique_parachain/unique-chain/

# ===== BIN ======

FROM ubuntu:22.04 as builder-polkadot

COPY --from=builder-polkadot-bin /unique_parachain/unique-chain/unique-collator /bin/unique-collator
ENTRYPOINT ["/bin/unique-collator"]
16 changes: 0 additions & 16 deletions .docker/docker-compose.node-only.j2

This file was deleted.

59 changes: 59 additions & 0 deletions .github/actions/buildContainer/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build or pull container
description: ''
inputs:
container:
description: Which name to fetch/push
required: true
tag:
description: Which tag to fetch/push
required: true
context:
description: Container context
required: true
default: "."
dockerfile:
description: Path to dockerfile (relative to context)
required: true
args:
description: Docker build extra args
default: ''
dockerhub_username:
description: Secret
dockerhub_token:
description: Secret
outputs:
name:
description: Full container name
value: ${{ steps.ensure.outputs.name }}
runs:
using: "composite"
steps:
- name: Ensure have ${{ inputs.container }}:${{ inputs.tag }}
id: ensure
run: |
echo "Wanted container: ${{ inputs.container }}:${{ inputs.tag }}"
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${{ inputs.dockerhub_username }}'", "password": "'${{ inputs.dockerhub_token }}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
# Get TAGS from DOCKERHUB
TAGS=$(curl -s -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/${{ inputs.container }}/tags/?page_size=100 | jq -r '."results"[]["name"]' || echo "")
echo "Available tags:"
echo "$TAGS"
# Check correct version POLKADOT and build it if it doesn't exist in POLKADOT TAGS
if [[ ${TAGS[*]} =~ (^|[[:space:]])"${{ inputs.tag }}"($|[[:space:]]) ]]; then
echo "Repository has needed version, pulling";
docker pull ${{ inputs.container }}:${{ inputs.tag }}
else
echo "Repository had no needed version, so build it";
cd "${{ inputs.context }}" && docker build --file "${{ inputs.dockerfile }}" \
$BUILD_ARGS --tag ${{ inputs.container }}:${{ inputs.tag }} \
.
echo "Push built version to the repository";
docker push ${{ inputs.container }}:${{ inputs.tag }} || true
fi
echo "name=${{ inputs.container }}:${{ inputs.tag }}" >> $GITHUB_OUTPUT
env:
BUILD_ARGS: ${{ inputs.args }}
shell: bash
Loading

0 comments on commit a0b6705

Please sign in to comment.