Skip to content

Commit

Permalink
Updated release and build script to build bundle version and non-bund…
Browse files Browse the repository at this point in the history
…le version
  • Loading branch information
maoueh committed Sep 28, 2022
1 parent 5f34975 commit 7c7b538
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 84 deletions.
148 changes: 117 additions & 31 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
---
name: Build docker image

on:
push:
tags:
- "v*"
branches:
- "master"
- "develop"
- "release/v*"
- "*"
workflow_dispatch:
inputs:
thegarii_version:
description: 'version of thegarii to use (if not specified, will use latest)'
required: false
type: string

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
build-vanilla:
runs-on: ubuntu-20.04

permissions:
Expand All @@ -31,12 +34,14 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- uses: actions/cache@v3
- name: Set up Go cache
uses: actions/cache@v3
id: cache-go
with:
path: |
Expand All @@ -46,18 +51,7 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- uses: actions/cache@v3
id: cache-rust
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Branch name
- name: Print branch name
id: extract_branch
shell: bash
run: |
Expand All @@ -81,8 +75,7 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha,prefix=,enable=${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/release/v') }}
type=raw,enable=${{ github.ref == 'refs/heads/master' }},value=master
type=sha,prefix=,enable=true
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
flavor: |
Expand All @@ -96,15 +89,108 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# slack-notifications:
# needs: [build]
# runs-on: ubuntu-20.04
# steps:
# - name: Slack notification
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# uses: Ilshidur/action-slack@2.0.2
# with:
# args: |
# :done: *${{ github.repository }}* Success building docker image from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}```
build-bundle:
needs: build-vanilla
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}

permissions:
contents: read
packages: write

outputs:
image: ${{ steps.print.outputs.image }}

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

- name: Branch name
id: extract_branch
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=release_train;]$(echo ${GITHUB_REF#refs/heads/release/})"
- name: Set default thegarii version
if: ${{ github.event.inputs.thegarii_version == '' }}
id: thegarii_version_default
run: |
echo THEGARII_VERSION=latest >> $GITHUB_ENV
- name: Set thegarii version from input
if: ${{ github.event.inputs.thegarii_version != '' }}
id: thegarii_version_input
run: |
echo THEGARII_VERSION=$(echo "${THEGARII_VERSION_INPUT}") >> $GITHUB_ENV
env:
THEGARII_VERSION_INPUT: ${{ github.event.inputs.thegarii_version }}

- name: Set versions
shell: bash
run: |
docker pull ghcr.io/streamingfast/thegarii:${{ env.THEGARII_VERSION }}
echo VERSION=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' 'ghcr.io/streamingfast/thegarii':${{ env.THEGARII_VERSION }}) >> $GITHUB_ENV
echo SF_VERSION=$(echo "${{ needs.build-vanilla.outputs.tags }}" | grep -Ev "(develop)" | head -n 1 |cut -d: -f2) >> $GITHUB_ENV
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag,suffix=-${{ env.VERSION }}
type=sha,prefix=,suffix=-${{ env.VERSION }},enable=true
type=raw,prefix=,suffix=-${{ env.VERSION }},enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,prefix=,suffix=-${{ env.VERSION }},enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
flavor: latest=false

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./Dockerfile.bundle
build-args: |
THEGARII_VERSION=${{ env.THEGARII_VERSION }}
SF_VERSION=${{ env.SF_VERSION }}
- id: print
run: |
OUT="${{ steps.meta.outputs.tags }}"
OUT="${OUT//'%'/'%25'}"
OUT="${OUT//$'\n'/'%0A'}"
OUT="${OUT//$'\r'/'%0D'}"
echo "::set-output name=image::$OUT"
slack-notifications-vanilla:
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.event_name != 'workflow_dispatch' }}
needs: [build-vanilla]
runs-on: ubuntu-20.04
steps:
- name: Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/action-slack@2.0.2
with:
args: |
:done: *${{ github.repository }}* Success building docker image from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}```
slack-notifications:
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
needs: [build-vanilla, build-bundle]
runs-on: ubuntu-20.04
steps:
- name: Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/action-slack@2.0.2
with:
args: |
:done: *${{ github.repository }}* Success building docker images from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}
${{ needs.build-bundle.outputs.image }}```
27 changes: 9 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# syntax=docker/dockerfile:1.2

# TODO: Move that to `thegarii` repo so we can pull it?
# thegarii builder
FROM rust:bullseye as thegarii-builder
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN --mount=type=cache,target=/var/cache/apk \
--mount=type=cache,target=/home/rust/.cargo \
rustup component add rustfmt \
&& git clone https://github.com/streamingfast/thegarii \
&& cd thegarii \
&& cargo build --release \
&& cp target/release/thegarii /home/rust/

FROM ubuntu:20.04

RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
Expand All @@ -21,12 +7,17 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
rm -rf /var/cache/apt /var/lib/apt/lists/*

RUN rm /etc/localtime && ln -snf /usr/share/zoneinfo/America/Montreal /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
RUN mkdir -p /app/ && curl -Lo /app/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.12/grpc_health_probe-linux-amd64 && chmod +x /app/grpc_health_probe

ADD /firearweave /app/firearweave
COPY --from=thegarii-builder /home/rust/thegarii /app/thegarii

# TODO: Add back later
# COPY tools/sfeth/motd_generic /etc/
# COPY tools/sfeth/99-sfeth-generic.sh /etc/profile.d/
COPY tools/firearweave/motd_generic /etc/motd
COPY tools/firearweave/99-firehose.sh /etc/profile.d/

# On SSH connection, /root/.bashrc is invoked which invokes '/root/.bash_aliases' if existing,
# so we hijack the file to "execute" our specialized bash script
RUN echo ". /etc/profile.d/99-firehose.sh" > /root/.bash_aliases

ENV PATH "$PATH:/app"

ENTRYPOINT ["/app/firearweave"]
10 changes: 10 additions & 0 deletions Dockerfile.bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG THEGARII_VERSION=latest
ARG SF_VERSION=latest

FROM ghcr.io/streamingfast/thegarii:$THEGARII_VERSION as chain
FROM ghcr.io/streamingfast/firehose-arweave:$SF_VERSION

COPY --from=chain /app/thegarii /app/thegarii

COPY tools/firearweave/motd_node_manager /etc/motd
COPY tools/firearweave/scripts/. /usr/local/bin/
18 changes: 0 additions & 18 deletions tools/fireacme/99-firehose-arweave.sh

This file was deleted.

17 changes: 0 additions & 17 deletions tools/fireacme/scripts/acme-rpc-head-block

This file was deleted.

7 changes: 7 additions & 0 deletions tools/firearweave/99-firehose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##
# This is place inside `/etc/profile.d/99-firehose-arweave.sh`
# on built system an executed to provide message to use when they
# connect on the box.
export PATH=$PATH:/app

cat /etc/motd
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 7c7b538

Please sign in to comment.