Test Docker Image Build run #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Github workflow to build a multiarch docker image from pre-built binaries | |
name: Docker Image (Binary) | |
on: | |
workflow_call: | |
inputs: | |
tag: | |
required: true | |
type: string | |
description: "Version tag for docker images" | |
workflow_dispatch: | |
push: | |
branches: | |
- 693-chore-docker-container-publishing | |
## Define which docker arch to build for | |
env: | |
docker_platforms: "linux/amd64" | |
docker-org: blockstack | |
rc-version: v0.0.1 | |
concurrency: | |
group: docker-image-binary-${{ github.head_ref || github.ref || github.run_id }} | |
## Always cancel duplicate jobs | |
cancel-in-progress: true | |
run-name: "Test Docker Image Build run" | |
jobs: | |
## Runs when the following is true: | |
## - tag is provided | |
## - workflow is building default branch (master) | |
image: | |
name: Build Image | |
strategy: | |
fail-fast: false | |
## Build a maximum of 2 images concurrently based on matrix.dist | |
max-parallel: 2 | |
matrix: | |
dist: | |
- debian | |
docker_target: | |
- signer | |
runs-on: ubuntu-latest | |
steps: | |
## Setup Docker for the builds | |
- name: Docker setup | |
id: docker_setup | |
uses: stacks-network/actions/docker@main | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id) | |
## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username) | |
- name: Set Local env vars | |
id: set_env | |
if: | | |
github.repository_owner != 'stacks-network' | |
run: | | |
echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV" | |
## Set docker metatdata | |
## - depending on the matrix.dist, different tags will be enabled | |
## ex. debian will have this tag: `type=ref,event=tag,enable=${{ matrix.dist == 'debian' }}` | |
- name: Docker Metadata ( ${{ matrix.dist }} ) | |
id: docker_metadata | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1 | |
with: | |
## tag images with current repo name `stacks-core` as well as legacy `stacks-blockchain` | |
# ${{ env.docker-org }}/${{ github.event.repository.name }} | |
images: | | |
${{ env.docker-org }}/sbtc | |
tags: | | |
type=raw,value=${{ matrix.docker_target }}-latest,enable=${{ matrix.docker_target != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'debian' }} | |
type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }}-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && matrix.dist == 'debian'}} | |
type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }},enable=${{ matrix.docker_target != '' && matrix.dist == 'debian' }} | |
type=ref,event=tag,enable=${{ matrix.dist == 'debian' }} | |
type=raw,value=${{ matrix.docker_target }}-latest-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ) && matrix.dist == 'alpine' }} | |
type=raw,value=${{ matrix.docker_target }}-${{ env.rc-version }}-${{ matrix.dist }},enable=${{ matrix.docker_target != '' && matrix.dist == 'alpine' }} | |
## Build docker image for release | |
- name: Build and Push ( ${{ matrix.dist }} ${{ matrix.docker_target }} ) | |
id: docker_build | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
with: | |
file: ./.github/actions/dockerfiles/Dockerfile.signer.test.${{ matrix.dist }} | |
platforms: ${{ env.docker_platforms }} | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
target: ${{ matrix.docker_target }} | |
build-args: | | |
TAG=${{ matrix.docker_target }} | |
REPO=${{ github.repository_owner }}/${{ github.event.repository.name }} | |
STACKS_NODE_VERSION=${{ matrix.docker_target || env.GITHUB_SHA_SHORT }} | |
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }} | |
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }} | |
push: ${{ env.DOCKER_PUSH }} |