Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update nova deploy workflow with sdk build #932

Merged
merged 18 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions .github/workflows/nova-build-temp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Nova Deply Workflow (with SDK build)

on:
workflow_dispatch:
inputs:
TARGET_COMMIT:
description: 'Target Commit Hash for the SDK'
required: false
default: '05b7cec884177ba11c8848d0d52c850a8bb496fe'
environment:
type: choice
description: 'Select the environment to deploy to'
options:
- nova
required: false
default: nova
deployment:
type: boolean
description: 'Deploy after build?'
required: false
default: false

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}

- name: Get the short commit hash
run: |
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "VERSION=$COMMIT_HASH" >> $GITHUB_ENV

- name: Set up Environment Variable
run: echo "DEPLOY_ENV=${{ github.event.inputs.environment }}" >> $GITHUB_ENV

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y python2 gcc-multilib g++-multilib build-essential libssl-dev rpm libsecret-1-dev software-properties-common apt-transport-https libudev-dev libusb-1.0-0-dev llvm-dev libclang-dev clang yarn
echo 'LIBCLANG_PATH=/usr/lib/llvm-14/lib' >> $GITHUB_ENV
echo 'DEBUG=electron-builder' >> $GITHUB_ENV
echo 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/snap:/root/.cargo/bin' >> $GITHUB_ENV

- name: Install Rust and wasm-bindgen-cli
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
cargo install wasm-bindgen-cli
rustup target add wasm32-unknown-unknown

- name: Global Git Configuration
run: git config --global --add safe.directory ${{ github.workspace }}

- name: Yarn Add crypto-browserify
run: yarn add crypto-browserify

- name: Setup SDK
run: |
git clone -b 2.0 https://github.com/iotaledger/iota-sdk
cd iota-sdk
echo "Checking out nova-sdk commit ${{ github.event.inputs.TARGET_COMMIT }}"
git checkout ${{ github.event.inputs.TARGET_COMMIT }}

- name: Build Node.js Bindings
run: |
cd iota-sdk/bindings/nodejs
echo "Renaming nodejs sdk (sdk-nova)"
sed -i.bak '2s/.*/ \"name\": \"@iota\/sdk-nova\",/' package.json
rm package.json.bak
echo "Building nodejs bindings"
source $HOME/.cargo/env
yarn
yarn build

- name: Build WASM Bindings
run: |
cd iota-sdk/bindings/wasm
echo "Renaming wasm sdk (sdk-wasm-nova)"
sed -i.bak '2s/.*/ \"name\": \"@iota\/sdk-wasm-nova\",/' package.json
rm package.json.bak
echo "Building wasm bindings"
source $HOME/.cargo/env
yarn
yarn build

- name: Build and push API Docker image
uses: docker/build-push-action@v2
with:
context: ./
file: ./api/Dockerfile
push: true
tags: iotaledger/explorer-api:${{ env.VERSION }}
no-cache: true

- name: Build and push Client Docker image
uses: docker/build-push-action@v2
with:
context: ./
file: ./client/Dockerfile
push: true
tags: iotaledger/explorer-client:${{ env.VERSION }}
no-cache: true

- name: Add SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.UPDATER_SSH_PRIVATE_KEY }}

- name: Deploy to Server
if: ${{ github.event.inputs.deployment }}
run: |
ssh -o StrictHostKeyChecking=no updater@${{ secrets.EXPLORER_NOVA_GATEWAY }} "${{ env.DEPLOY_ENV }} ${{ env.VERSION }}"

22 changes: 20 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
FROM node:16.20.2-bullseye

## Include the build tools for any npm packages that rebuild
RUN apt install git curl python3
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
libudev-dev \
cmake \
clang \
curl \
git \
python3 \
&& rm -rf /var/lib/apt/lists/*

# Working DIR
WORKDIR /usr/src/app

# Copy everything from current Folder
COPY . ./
# COPY . ./

# Copy iota-sdk-nova deps REMOVE THIS for prod
# Get Rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="${PATH}:/root/.cargo/bin"

COPY ./api ./
COPY ./iota-sdk/ ../iota-sdk/

# Set the env variables
ARG CONFIG_ID
Expand Down
4 changes: 2 additions & 2 deletions api/src/initServices.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MqttClient as ChrysalisMqttClient } from "@iota/mqtt.js";
import { Client as StardustClient } from "@iota/sdk";
import { initLogger, Client as NovaClient } from "@iota/sdk-nova";
import { Client as NovaClient } from "@iota/sdk-nova";
import { ServiceFactory } from "./factories/serviceFactory";
import logger from "./logger";
import { IConfiguration } from "./models/configuration/IConfiguration";
Expand Down Expand Up @@ -30,7 +30,7 @@ import { NodeInfoService as NodeInfoServiceStardust } from "./services/stardust/
import { StardustStatsService } from "./services/stardust/stats/stardustStatsService";

// iota-sdk debug
initLogger();
// initLogger();

const CURRENCY_UPDATE_INTERVAL_MS = 5 * 60000;

Expand Down
10 changes: 9 additions & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ RUN apt-get update && apt-get install -y \
WORKDIR /usr/src/app

# Copy everything from current Folder
COPY . ./
# COPY . ./

# Copy iota-sdk-nova deps REMOVE THIS for prod
# Get Rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="${PATH}:/root/.cargo/bin"

COPY ./client ./
COPY ./iota-sdk/ ../iota-sdk/

# A minimal NGINX configuration
RUN echo 'server {\
Expand Down