Skip to content

Commit

Permalink
ci: add container build workflow for fork
Browse files Browse the repository at this point in the history
We cannot depend on the upstream `informalsystems/hermes` repo for CI
deployments, because we need the forked Hermes code for compatiblity
with Penumbra chains. Added a new workflow that will publish as
`ghcr.io/penumbra-zone/hermes`, and removed the informalsystems one.
  • Loading branch information
conorsch committed Apr 9, 2024
1 parent f760c7e commit ad07153
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 140 deletions.
17 changes: 7 additions & 10 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/.changelog/
/.git/
/.gitignore
/.github
/ci/
/docs/
/e2e/
/guide/
/scripts/
/target/
# ignore everything
**
# selectively un-ignore rust files
!crates/
!tools/
!Cargo.*
!.cargo/config.toml
71 changes: 71 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
name: Build container image
on:
workflow_call:
workflow_dispatch:
inputs:
penumbra_version:
description: 'Git ref (e.g. branch or tag) of Penumbra repo for building'
default: "main"
required: true
# Support triggering builds from penumbra-zone/penumbra CI.
repository_dispatch:
types:
- container-build
inputs:
penumbra_version:
description: 'Git ref (e.g. branch or tag) of Penumbra repo for building'
default: "main"
required: true
push:
branches:
- main
tags:
- '**'
jobs:
hermes:
runs-on: buildjet-16vcpu-ubuntu-2004
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Docker Hub container registry (for pulls)
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the GitHub container registry (for pushes)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/penumbra-zone/hermes

- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
file: ci/release/Containerfile
push: true
# We include a tag with the associated Penumbra, e.g. `penumbra-v0.61.0`.
# This is important to maintain compatibility with a long-running testnet.
tags: ${{ steps.meta.outputs.tags }},ghcr.io/penumbra-zone/hermes:penumbra-${{ github.event.inputs.penumbra_version || 'main' }}
build-args: |
PENUMBRA_VERSION=${{ github.event.inputs.penumbra_version || 'main' }}
# We disable layer caching to ensure that the most recent penumbra repo is used.
# Otherwise, the static git url for the repo will always result in a cache hit.
# TODO: update with dynamic build-args using e.g. current date to bust cache.
no-cache: true
labels: ${{ steps.meta.outputs.labels }}
130 changes: 0 additions & 130 deletions .github/workflows/docker.yml

This file was deleted.

37 changes: 37 additions & 0 deletions ci/release/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM docker.io/rust:1-bookworm AS builder
COPY . /usr/src/hermes
WORKDIR /usr/src/hermes

# Install build dependencies. These packages should match what's recommended on
# https://guide.penumbra.zone/main/pcli/install.html
RUN apt-get update && apt-get install -y \
git-lfs \
build-essential \
pkg-config \
libssl-dev \
clang

# Support building from a specific git dependency of the upstream Penumbra repo.
# N.B. As of 2024-04, the Hermes fork only builds against v0.68.1 of Penumbra,
# so we'll hardcode that version for now. Once we have the deps up to date,
# we should support overrides like "main" to predict breaking changes.
# ARG PENUMBRA_VERSION=main
ARG PENUMBRA_VERSION="v0.68.1"

# ARG PENUMBRA_VERSION=v0.61.0
# Set the desired PENUMBRA_VERSION in the Cargo.toml file prior to building.
# RUN sed -i -e "s/^\(penumbra-.*\)\(tag = \".*\"\)\(.*\)$/\1branch = \"${PENUMBRA_VERSION}\"\3/" ./crates/relayer/Cargo.toml \
# && cat ./crates/relayer/Cargo.toml
RUN cargo build --release

# Runtime container, with binary and normal user account.
FROM docker.io/debian:bookworm-slim
LABEL maintainer="[email protected]"

COPY --from=builder /usr/src/hermes/target/release/hermes /usr/bin/hermes
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
RUN groupadd --gid 1000 hermes \
&& useradd -m -d /home/hermes -g 1000 -u 1000 hermes
WORKDIR /home/hermes
USER hermes
ENTRYPOINT ["/usr/bin/hermes"]

0 comments on commit ad07153

Please sign in to comment.