Skip to content

Test Docker Image Build run #9

Test Docker Image Build run

Test Docker Image Build run #9

Workflow file for this run

## 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/arm64, linux/amd64, linux/arm/v7, linux/amd64/v3, linux/arm64/v8"
docker_platforms: "linux/arm64, linux/amd64"
docker-org: blockstack
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
runs-on: ubuntu-latest
strategy:
fail-fast: false
## Build a maximum of 2 images concurrently based on matrix.dist
max-parallel: 3
matrix:
dist:
- debian
docker_target:
- signer
- emily-server
- blocklist-client
steps:
## Setup Docker for the builds
- name: Docker setup
id: docker_setup
uses: stacks-network/actions/docker@main
with:
username: ${{ secrets.ASHTON_DOCKERHUB_USERNAME }}
password: ${{ secrets.ASHTON_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"
- name: Set Local env vars
id: set_env
run: |
echo "docker-org=ashtontm" >> "$GITHUB_ENV"
echo "rc-version=0.0.1" >> "$GITHUB_ENV"
echo "docker-repo=test" >> "$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}}/${{env.docker-repo}}
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.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 }}