Skip to content

Docker

Docker #525

Workflow file for this run

---
name: Docker
# Build & Push rebuilds the Tenderdash docker image every time a release is
# published and pushes the image to https://hub.docker.com/r/dashpay/tenderdash
on:
workflow_dispatch:
inputs:
tag:
type: string
description: "Docker tag"
required: false
platforms:
type: choice
description: "Image architecture to build"
default: "linux/amd64,linux/arm64"
options:
- "linux/amd64,linux/arm64"
- "linux/amd64"
- "linux/arm64"
release:
types:
- published
jobs:
build:
runs-on: ubuntu-22.04
env:
PLATFORMS: ${{ github.event_name == 'release' && 'linux/amd64,linux/arm64' || github.event.inputs.platforms }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3.3.0
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set suffix to Docker tags
uses: actions/github-script@v6
id: suffix
if: ${{ github.event.release != null }}
with:
result-encoding: string
script: "return (context.payload.release.tag_name.includes('-dev') ? '-dev' : '');"
- name: Determine TENDERMINT_BUILD_OPTIONS
uses: actions/github-script@v6
id: TENDERMINT_BUILD_OPTIONS
with:
result-encoding: string
script: |
if ('${{ github.ref_type }}' == 'tag' && ! '${{ github.ref_name }}'.includes('-dev')) {
return 'tenderdash,stable'
}
return 'tenderdash,dev,deadlock'
- name: Set Docker tags and labels
id: docker_meta
uses: docker/metadata-action@v5
with:
images: dashpay/tenderdash
tags: |
type=semver,pattern={{version}},value=${{ github.event.inputs.tag }}
type=raw,priority=650,value=${{ github.event.inputs.tag }},enable=${{ github.event.inputs.tag != '' }}
type=ref,event=branch
type=ref,event=pr
type=match,pattern=v(\d+),group=1
type=match,pattern=v(\d+.\d+),group=1
type=match,pattern=v(\d+.\d+.\d+),group=1
type=match,pattern=v(.*),group=1,suffix=,enable=${{ contains(github.event.release.tag_name, '-dev') }}
flavor: |
latest=${{ github.event.release != null && !contains(github.event.release.tag_name, '-dev') }}
suffix=${{ steps.suffix.outputs.result }}
# We build some dependencies and libraries separately. Layers are cached
# on Docker Hub, as Github caches are not available for other branches.
- name: Build and cache image with dependencies
id: docker_bls
uses: docker/build-push-action@v5.3.0
with:
context: .
file: ./DOCKER/Dockerfile
platforms: ${{ env.PLATFORMS }}
target: base
push: false
cache-from: |
type=registry,ref=dashpay/tenderdash:buildcache-deps
cache-to: |
type=registry,ref=dashpay/tenderdash:buildcache-deps,mode=max
build-args: |
TENDERMINT_BUILD_OPTIONS="${{ steps.TENDERMINT_BUILD_OPTIONS.outputs.result }}"
- name: Publish to Docker Hub
id: docker_build
uses: docker/build-push-action@v5.3.0
with:
context: .
file: ./DOCKER/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: |
type=gha
type=registry,ref=dashpay/tenderdash:buildcache-deps
cache-to: type=gha,mode=max
build-args: |
TENDERMINT_BUILD_OPTIONS="${{ steps.TENDERMINT_BUILD_OPTIONS.outputs.result }}"
- name: Show Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}