mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 15:55:18 +00:00
967c6857e8
* build & publish rocksdb docker images merge to master * publish docker images on push of release version tags NOTE: New docker image tag pattern. ALL tags now include database suffix ex. <githash>-goleveldb, v0.25.0-alpha.1-rocksdb, master-rocksdb, etc * update dockerfiles for better caching * update all github action workflow versions * improve caching of go packages * cache docker image layers for reuse between runs * update dockerignore to remove non-essential files
103 lines
3.4 KiB
YAML
103 lines
3.4 KiB
YAML
name: Build & Publish Docker Images
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
dockerhub-username:
|
|
required: true
|
|
type: string
|
|
# this workflow publishes a rocksdb & goleveldb docker images with these tags:
|
|
# - <commit-hash>-goleveldb
|
|
# - <extra-image-tag>-goleveldb
|
|
# - <commit-hash>-rocksdb
|
|
# - <extra-image-tag>-rocksdb
|
|
extra-image-tag:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
CI_DOCKERHUB_TOKEN:
|
|
required: true
|
|
|
|
# runs in ci-master after successful checks
|
|
# you can use images built by this action in future jobs.
|
|
# https://docs.docker.com/build/ci/github-actions/examples/#share-built-image-between-jobs
|
|
jobs:
|
|
docker-goleveldb:
|
|
# https://github.com/marketplace/actions/build-and-push-docker-images
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# ensure working with latest code
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# generate a git commit hash to be used as image tag
|
|
- name: Generate short hash
|
|
id: commit-hash
|
|
run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
|
|
|
|
# qemu is used to emulate different platform architectures
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
# cross-platform build of the image
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# authenticate for publish to docker hub
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ inputs.dockerhub-username }}
|
|
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
|
|
|
|
# publish to docker hub, tag with short git hash
|
|
- name: Build and push (goleveldb)
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: kava/kava:${{ steps.commit-hash.outputs.short }}-goleveldb,kava/kava:${{ inputs.extra-image-tag }}-goleveldb
|
|
|
|
docker-rocksdb:
|
|
# https://github.com/marketplace/actions/build-and-push-docker-images
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
# ensure working with latest code
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# generate a git commit hash to be used as image tag
|
|
- name: Generate short hash
|
|
id: commit-hash
|
|
run: echo "short=$( git rev-parse --short $GITHUB_SHA )" >> $GITHUB_OUTPUT
|
|
|
|
# qemu is used to emulate different platform architectures
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
# cross-platform build of the image
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# authenticate for publish to docker hub
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ inputs.dockerhub-username }}
|
|
password: ${{ secrets.CI_DOCKERHUB_TOKEN }}
|
|
|
|
# publish to docker hub, tag with short git hash
|
|
- name: Build and push (rocksdb)
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: Dockerfile-rocksdb
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: kava/kava:${{ steps.commit-hash.outputs.short }}-rocksdb,kava/kava:${{ inputs.extra-image-tag }}-rocksdb
|