Skip to content

Commit

Permalink
Build DSN docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zaikin committed Jan 4, 2024
1 parent 0ed24d9 commit 1fad9c1
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 139 deletions.
7 changes: 6 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
target/
target/
benchmark/
bin/
.tezos-client/
.db/
.git/
101 changes: 101 additions & 0 deletions .github/workflows/kernel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build & deploy DSN kernel

on:
push:
branches:
- 'master'
tags:
- '*.*.*'
pull_request:
branches:
- 'master'

jobs:
build:
name: Build and push docker images
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_BASE: ${{ github.repository_owner }}
outputs:
operator: ${{ steps.meta-dsn-operator.outputs.tags }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

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

- name: Log in to the registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: DSN operator tags & labels
id: meta-dsn-operator
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/operator

- name: DSN operator build & push
uses: docker/build-push-action@v2
with:
context: .
file: build/kernel/Dockerfile
build-args: |
OCTEZ_TAG=v17.1
OCTEZ_PROTO=PtNairob
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta-dsn-operator.outputs.tags }}
labels: ${{ steps.meta-dsn-operator.outputs.labels }}

deploy:
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || (github.event_name == 'push' && github.ref == 'refs/heads/master')
name: Deploy DSN kernel to testnet
needs: build
runs-on: ubuntu-latest
env:
NETWORK: nairobinet
steps:
- name: Deploy rollup
run: docker run -v "/var/run/docker.sock":"/var/run/docker.sock" -e NETWORK=${{ env.NETWORK }} -e OPERATOR_KEY=${{ secrets.OPERATOR_KEY }} ${{ needs.build.outputs.operator }} deploy_rollup | tee originate.out

- name: Extract rollup address
run: |
ROLLUP_ADDRESS=$(cat originate.out | grep -oE "sr1[a-zA-Z0-9]{33}" | uniq | tr -d '\n')
echo "ROLLUP_ADDRESS=$ROLLUP_ADDRESS" >> $GITHUB_ENV
- name: Update PR with the deployment link
if: github.event_name == 'pull_request'
uses: edumserrano/find-create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body-includes: '<!-- pr-rollup-deployment -->'
comment-author: 'github-actions[bot]'
body: |
<!-- pr-rollup-deployment -->
Deployed at [${{ env.ROLLUP_ADDRESS }}](https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }})
edit-mode: replace
reactions: rocket

- name: Create GitHub deployment
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: altinukshini/deployment-action@releases/v1
id: deployment
with:
token: "${{ github.token }}"
environment: ${{ env.NETWORK }}

- name: Update deployment status
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: altinukshini/deployment-status@releases/v1
with:
token: "${{ github.token }}"
state: "success"
environment_url: https://${{ env.NETWORK }}.tzkt.io/${{ env.ROLLUP_ADDRESS }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
50 changes: 50 additions & 0 deletions .github/workflows/sequencer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build DSN nodes

on:
push:
branches:
- 'master'
tags:
- '*.*.*'
pull_request:
branches:
- 'master'

jobs:
build:
name: Build and push docker images
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_BASE: ${{ github.repository_owner }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

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

- name: Log in to the registry
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: DSN image tags & labels
id: meta-sequencer
uses: docker/metadata-action@v3
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/sequencer

- name: DSN image build & push
uses: docker/build-push-action@v2
with:
context: .
file: build/sequencer/Dockerfile
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta-sequencer.outputs.tags }}
labels: ${{ steps.meta-sequencer.outputs.labels }}
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ members = [
"crates/worker",
"crates/pre-block",

"executor",
"launcher",
"playground",
"kernel",
Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ image-operator:
--build-arg OCTEZ_PROTO=$(OCTEZ_PROTO) \
.

image-sequencer:
docker build -t dsn/sequencer --file ./docker/sequencer/Dockerfile .

run-operator:
$(MAKE) build-operator
$(MAKE) image-operator OCTEZ_TAG=$(OCTEZ_TAG) OCTEZ_PROTO=$(OCTEZ_PROTO)
Expand All @@ -61,3 +64,7 @@ run-operator:
run-sequencer:
$(MAKE) build-sequencer
RUST_LOG=info ./target/debug/sequencer

run-consensus:
cargo build --package launcher
./target/debug/launcher
19 changes: 19 additions & 0 deletions docker/sequencer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM rust:1.73-bullseye AS builder
ARG PROFILE=release
WORKDIR /build
RUN apt-get update && apt-get install -y cmake clang
COPY . ./
RUN cargo build --profile ${PROFILE} --bin narwhal-node
RUN cargo build --profile ${PROFILE} --bin sequencer

FROM debian:bullseye-slim AS runtime
# Use jemalloc as memory allocator
RUN apt-get update && apt-get install -y libjemalloc-dev
ENV LD_PRELOAD /usr/lib/x86_64-linux-gnu/libjemalloc.so
ARG PROFILE=release
COPY --from=builder build/target/${PROFILE}/narwhal-node /usr/bin/narwhal-node
COPY --from=builder build/target/${PROFILE}/sequencer /usr/bin/sequencer
COPY ./launcher/defaults/* /narwhal/
COPY ./docker/sequencer/entrypoint.sh .
RUN chmod +x entrypoint.sh && ln ./entrypoint.sh /usr/bin/narwhal
ENTRYPOINT [ "./entrypoint.sh" ]
31 changes: 31 additions & 0 deletions docker/sequencer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2023 Baking Bad <[email protected]>
#
# SPDX-License-Identifier: MIT

set -e

NARWHAL_NODE_BIN="/usr/bin/narwhal-node"

if [ -z "$VALIDATOR_ID" ]; then
echo "VALIDATOR_ID is not set"
exit 1
fi

LOG_LEVEL=${LOG_LEVEL:="-v"}
PRIMARY_KEYS_PATH=${KEYS_PATH:="/narwhal/primary-$VALIDATOR_ID.key"}
PRIMARY_NETWORK_KEYS_PATH=${KEYS_PATH:="/narwhal/primary-network-$VALIDATOR_ID.key"}
WORKER_NETWORK_KEYS_PATH=${KEYS_PATH:="/narwhal/worker-network-$VALIDATOR_ID.key"}
COMMITTEE_PATH=${COMMITTEE_PATH:="/narwhal/committee.json"}
WORKERS_PATH=${WORKERS_PATH:="/narwhal/workers.json"}
DATA_PATH=${DATA_PATH:="/data"}

$NARWHAL_NODE_BIN $LOG_LEVEL run-comb \
--primary-keys $PRIMARY_KEYS_PATH \
--primary-network-keys $PRIMARY_NETWORK_KEYS_PATH \
--worker-keys $WORKER_NETWORK_KEYS_PATH \
--committee $COMMITTEE_PATH \
--workers $WORKERS_PATH \
--primary-store "$DATA_PATH/primary-store-$VALIDATOR_ID" \
--worker-store "$DATA_PATH/worker-store-$VALIDATOR_ID"
17 changes: 0 additions & 17 deletions executor/Cargo.toml

This file was deleted.

4 changes: 0 additions & 4 deletions executor/build.rs

This file was deleted.

13 changes: 0 additions & 13 deletions executor/proto/executor.proto

This file was deleted.

31 changes: 0 additions & 31 deletions executor/src/client.rs

This file was deleted.

21 changes: 0 additions & 21 deletions executor/src/main.rs

This file was deleted.

36 changes: 0 additions & 36 deletions executor/src/server.rs

This file was deleted.

Loading

0 comments on commit 1fad9c1

Please sign in to comment.