Skip to content

Testnet dress-rehearsal tooling: leoma preflight (launch gate) + leom… #19

Testnet dress-rehearsal tooling: leoma preflight (launch gate) + leom…

Testnet dress-rehearsal tooling: leoma preflight (launch gate) + leom… #19

# Leoma Subnet - Docker Build and Push
#
# This workflow builds and pushes the Docker image to Docker Hub
# whenever code is pushed to the main branch.
#
# Validators using Watchtower will automatically pull the new image.
#
# Setup:
# 1. Create a Docker Hub account and repository
# 2. Create an access token at https://hub.docker.com/settings/security
# 3. Add secrets to your GitHub repo (Settings > Secrets > Actions):
# - DOCKERHUB_USERNAME: Your Docker Hub username
# - DOCKERHUB_TOKEN: Your Docker Hub access token
name: Build and Push Docker Image
on:
push:
branches:
- main
- master
# Only rebuild when relevant files change.
# NOTE: this used to watch 'leoma.py' (deleted) and NOT the package, so
# changes to the actual code never triggered a rebuild.
paths:
- 'leoma/**'
- 'pyproject.toml'
- 'Dockerfile'
- 'Dockerfile.eval'
- '.github/workflows/docker-publish.yml'
# Allow manual trigger for testing
workflow_dispatch:
env:
REGISTRY: docker.io
# Change this to your Docker Hub username and repo name
# Format: username/repository
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
# Slim CPU validator image.
- dockerfile: Dockerfile
suffix: ""
# CUDA eval-server image (installs the [eval] extra).
- dockerfile: Dockerfile.eval
suffix: "-eval"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=${{ matrix.suffix }},onlatest=true
tags: |
# Tag as 'latest' for default branch
type=raw,value=latest,enable={{is_default_branch}}
# Tag with git SHA for rollback capability
type=sha,prefix=
# Tag with branch name
type=ref,event=branch
# Tag with version if tagged
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Cache layers for faster builds
cache-from: type=gha
cache-to: type=gha,mode=max
# amd64 only: the eval image is CUDA, and no validator runs on arm64.
platforms: linux/amd64
- name: Generate build summary
run: |
echo "## Docker Image Published 🐳" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Tags:**" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Validators running with Watchtower will automatically update within 5 minutes." >> $GITHUB_STEP_SUMMARY