Skip to content

Commit

Permalink
Add kava archival build
Browse files Browse the repository at this point in the history
  • Loading branch information
david-terra committed Jan 26, 2024
1 parent 421e6c5 commit cec134f
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ on:
required: false
type: string
default: ""
rocksdb_version:
description: "RocksDB version"
required: false
type: string
default: ""
name:
description: "Name of the application"
required: true
Expand Down Expand Up @@ -173,3 +178,4 @@ jobs:
GO_VERSION=${{ inputs.go_version }}
LDFLAGS=${{ inputs.ldflags }}
MIMALLOC_VERSION=${{ inputs.mimalloc_version }}
ROCKSDB_VERSION=${{ inputs.rocksdb_version }}
66 changes: 66 additions & 0 deletions .github/workflows/kava-rocksdb-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: kava-build

on:
pull_request:
branches:
- main
paths:
- 'bin/builder'
- 'arch.Dockerfile'
- 'alpine.Dockerfile'
- '.github/workflows/docker-build.yml'
- '.github/workflows/kava-build.yml'

push:
branches:
- main
paths:
- 'bin/builder'
- 'arch.Dockerfile'
- 'alpine.Dockerfile'
- '.github/workflows/docker-build.yml'
- '.github/workflows/kava-build.yml'

jobs:
kava-build:
uses: ./.github/workflows/docker-build.yml
secrets: inherit
strategy:
fail-fast: false
matrix:
#platform: ["linux/amd64", "linux/arm64"] # need arm runners
platform: ["linux/amd64"]
distro: ["alpine"]
version:
- "0.25.0"

include:
# Include Defaults (keep at top)
- name: "kava-rocksdb"
binary: "kava"
build_command: "make install"
chain_registry_name: "kava"
repo: "Kava-Labs/kava"
go_version: "1.20"
os: "linux"
arch: "amd64"
rocksdb_version: "8.1.1"
cosmos_build_options: "nostrip rocksdb"

- version: "0.25.0"
go_version: "1.20"

with:
binary: ${{ matrix.binary }}
build_command: ${{ matrix.build_command }}
chain_registry_name: ${{ matrix.chain_registry_name }}
go_version: ${{ matrix.go_version }}
name: ${{ matrix.name }}
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
distro: ${{ matrix.distro }}
platform: ${{ matrix.platform }}
repo: ${{ matrix.repo }}
version: ${{ matrix.version }}
rocksdb_version: ${{ matrix.rocksdb_version }}
denom: ukava
8 changes: 7 additions & 1 deletion alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN set -eu && \
gcompat \
git

COPY ./bin/install-mimalloc ./bin/install-wasmvm /usr/local/bin/
COPY ./bin/install-mimalloc ./bin/install-wasmvm ./bin/install-rocksdb /usr/local/bin/

################################################################################
FROM base as builder
Expand All @@ -29,13 +29,19 @@ ARG DENOM
ARG GIT_TAG="v2.4.1"
ARG GIT_REPO="terra-money/core"
ARG MIMALLOC_VERSION
ARG ROCKSDB_VERSION
ARG GO_VERSION

ENV MIMALLOC_VERSION=${MIMALLOC_VERSION}
# install mimalloc if version is specified
RUN set -eu && \
if [ -n "${MIMALLOC_VERSION}" ]; then install-mimalloc "${MIMALLOC_VERSION}"; fi

ENV ROCKSDB_VERSION=${ROCKSDB_VERSION}
# install rocksdb if version is specified
RUN set -eu && \
if [ -n "${ROCKSDB_VERSION}" ]; then install-rocksdb "${ROCKSDB_VERSION}"; fi

# download dependencies to cache as layer
WORKDIR ${GOPATH}/src/app

Expand Down
7 changes: 6 additions & 1 deletion arch.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN set -eu & \
tar -C / -xz && \
ln -s /go/bin/go /usr/local/bin/go

COPY ./bin/install-mimalloc ./bin/install-wasmvm /usr/local/bin/
COPY ./bin/install-mimalloc ./bin/install-wasmvm ./bin/install-rocksdb /usr/local/bin/

# ################################################################################
FROM base as builder
Expand All @@ -36,6 +36,11 @@ ENV MIMALLOC_VERSION=${MIMALLOC_VERSION}
RUN set -eu && \
if [ -n "${MIMALLOC_VERSION}" ]; then install-mimalloc "${MIMALLOC_VERSION}"; fi

ENV ROCKSDB_VERSION=${ROCKSDB_VERSION}
# install rocksdb if version is specified
RUN set -eu && \
if [ -n "${ROCKSDB_VERSION}" ]; then install-rocksdb "${ROCKSDB_VERSION}"; fi

# download dependencies to cache as layer
WORKDIR ${GOPATH}/src/app

Expand Down
19 changes: 19 additions & 0 deletions bin/install-rocksdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu

ROCKSDB_VERSION="$1"

if [ -n "${ROCKSDB_VERSION}" ]; then
mkdir -p "${GOPATH}/src/rocksdb"
cd "${GOPATH}/src/rocksdb"
git clone --depth 1 --branch "${ROCKSDB_VERSION}" \
https://github.com/facebook/rocksdb ./
# busybox install doesn't support -C flag
sed -i "s/install -C/install/g" Makefile
apk add zstd-static lz4-static zlib-static snappy-static
make -j$(nproc) static_lib
make install-static
else
echo "ROCKSDB_VERSION not set" >&2
exit 1
fi
35 changes: 35 additions & 0 deletions builds/kava-rocksdb.0.25.0.alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh -x

BASEDIR=$(dirname "$0")
DOCKER_DIR="${BASEDIR}/.."
IMAGE="alpine"
NAME="kava-rocksdb"
REPO="Kava-Labs/kava"
TAG="0.25.0"
GO_VERSION="1.19"
ROCKSDB_VERSION="8.1.1"
COSMOS_BUILD_OPTIONS="nostrip rocksdb"

cd "${DOCKER_DIR}"
docker buildx build "." -f "${IMAGE}.Dockerfile" \
--load \
--progress plain \
--target "builder" \
--tag "terraformlabs/${NAME}:${TAG}" \
--platform "linux/amd64" \
--build-arg "OS=linux" \
--build-arg "ARCH=amd64" \
--build-arg "DENOM=ukava" \
--build-arg "APP_NAME=${NAME}" \
--build-arg "BIN_NAME=${NAME}" \
--build-arg "BUILD_COMMAND=make install" \
--build-arg "BUILD_TAGS=netgo ledger muslc" \
--build-arg "COSMOS_BUILD_OPTIONS=${COSMOS_BUILD_OPTIONS}" \
--build-arg "GIT_TAG=v${TAG}" \
--build-arg "GIT_REPO=${REPO}" \
--build-arg "GO_VERSION=${GO_VERSION}" \
--build-arg "MIMALLOC_VERSION=" \
--build-arg "ROCKSDB_VERSION=v${ROCKSDB_VERSION}" \
--build-arg "BIN_NAME=kava" \
--build-arg "LDFLAGS=-w -s -linkmode=external -extldflags \"-Wl,-z,muldefs -static\"" \
$@

0 comments on commit cec134f

Please sign in to comment.