Build container #16
Workflow file for this run
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
name: Build container | |
on: | |
workflow_dispatch: | |
inputs: | |
target: | |
description: target to build (see README) | |
required: true | |
type: choice | |
options: | |
- scilus | |
- scilpy | |
- dmriqcpy | |
- scilus-flows | |
tag: | |
description: tag to create for the image built | |
required: true | |
type: string | |
update-latest: | |
description: also push the latest tag in addition to the current one | |
required: false | |
type: boolean | |
default: false | |
scilpy-version: | |
description: scilpy version (release or branch name) | |
required: false | |
type: string | |
dmriqcpy-version: | |
description: dmriqcpy version (release or branch name) | |
required: false | |
type: string | |
scilus-dependencies-tag: | |
description: tag to fetch from dockerhub for scilus dependencies (base for scilus image) | |
required: false | |
type: string | |
default: latest | |
scilus-for-scilus-flows-tag: | |
description: tag to fetch from dockerhub for scilus (base for scilus-flows) | |
required: false | |
type: string | |
default: latest | |
nextflow-version: | |
description: nextflow version (format X.X.X) | |
required: false | |
type: string | |
build-system-ref: | |
description: github reference of the build system to checkout | |
required: false | |
type: string | |
default: main | |
workflow_call: | |
inputs: | |
target: | |
required: true | |
type: string | |
tag: | |
required: true | |
type: string | |
update-latest: | |
required: false | |
type: boolean | |
default: false | |
scilpy-version: | |
required: false | |
type: string | |
dmriqcpy-version: | |
required: false | |
type: string | |
python-version: | |
required: false | |
type: string | |
vtk-version: | |
required: false | |
type: string | |
nextflow-version: | |
required: false | |
type: string | |
base-install-image: | |
required: false | |
type: string | |
tractoflow-version: | |
required: false | |
type: string | |
dmriqc-flow-version: | |
required: false | |
type: string | |
extractor-flow-version: | |
required: false | |
type: string | |
rbx-flow-version: | |
required: false | |
type: string | |
tractometry-flow-version: | |
required: false | |
type: string | |
register-flow-version: | |
required: false | |
type: string | |
disconets-flow-version: | |
required: false | |
type: string | |
freewater-flow-version: | |
required: false | |
type: string | |
noddi-flow-version: | |
required: false | |
type: string | |
bst-flow-version: | |
required: false | |
type: string | |
build-system-ref: | |
required: false | |
type: string | |
default: main | |
secrets: | |
DOCKER_USERNAME: | |
description: 'Image repository on dockerhub to which to push' | |
required: true | |
DOCKER_PASSWORD: | |
description: 'Access token for dockerhub push' | |
required: true | |
jobs: | |
build-container: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Validate input parameters | |
run: | | |
if [ "${{ inputs.target }}" = "scilus-base" ] | |
then | |
echo "::error file=docker-builder.yml,line=109,title=scilus-base build::Github builder does not support building scilus-base for now" | |
fi | |
- | |
name: Checkout build system | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.repository_owner }}/containers-scilus | |
ref: ${{ inputs.build-system-ref }} | |
- | |
name: Resolve versioning from workflow inputs | |
id: local-versioning | |
run: | | |
touch local-versioning.hcl | |
echo "dockerhub-user-pull=\"${{ secrets.DOCKER_USERNAME }}\"" >> local-versioning.hcl | |
echo "dockerhub-user-push=\"${{ secrets.DOCKER_USERNAME }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.scilpy-version }}" ] || echo "scilpy-version=\"${{ inputs.scilpy-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.dmriqcpy-version }}" ] || echo "dmriqcpy-version=\"${{ inputs.dmriqcpy-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.nextflow-version }}" ] || echo "nextflow-version=\"${{ inputs.nextflow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.tractoflow-version }}" ] || echo "tractoflow-version=\"${{ inputs.tractoflow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.dmriqc-flow-version }}" ] || echo "dmriqc-flow-version=\"${{ inputs.dmriqc-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.extractor-flow-version }}" ] || echo "extractor-flow-version=\"${{ inputs.extractor-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.rbx-flow-version }}" ] || echo "rbx-flow-version=\"${{ inputs.rbx-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.tractometry-flow-version }}" ] || echo "tractometry-flow-version=\"${{ inputs.tractometry-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.register-flow-version }}" ] || echo "register-flow-version=\"${{ inputs.register-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.disconets-flow-version }}" ] || echo "disconets-flow-version=\"${{ inputs.disconets-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.freewater-flow-version }}" ] || echo "freewater-flow-version=\"${{ inputs.freewater-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.noddi-flow-version }}" ] || echo "noddi-flow-version=\"${{ inputs.noddi-flow-version }}\"" >> local-versioning.hcl | |
[ -z "${{ inputs.bst-flow-version }}" ] || echo "bst-flow-version=\"${{ inputs.bst-flow-version }}\"" >> local-versioning.hcl | |
echo "DEPS_TAG=\"${{ inputs.scilus-dependencies-tag }}\"" >> local-versioning.hcl | |
[ "${{ inputs.target }}" == "scilus-flows" ] && echo "SCILUS_TAG=\"${{ inputs.scilus-for-scilus-flows-tag }}\"" >> local-versioning.hcl | |
echo "bake-file=$PWD/local-versioning.hcl" >> $GITHUB_OUTPUT | |
- | |
name: Set output image tags and registry to publish to | |
id: dockerhub-tags | |
run: | | |
touch tag-publishing | |
echo "${{ inputs.target }}.output=type=registry" >> tag-publishing | |
echo "${{ inputs.target }}.tags=${{ secrets.DOCKER_USERNAME }}/${{ inputs.target }}:${{ inputs.tag }}" >> tag-publishing | |
[ "${{ inputs.disable-builddate-tag }}" != "true" ] && echo "${{ inputs.target }}.tags=${{ secrets.DOCKER_USERNAME }}/${{ inputs.target }}:${{ inputs.tag }}-$(date +'%Y%m%d')" | |
[ "${{ inputs.update-latest }}" == "true" ] && echo "${{ inputs.target }}.tags=${{ secrets.DOCKER_USERNAME }}/${{ inputs.target }}:latest" >> tag-publishing | |
DELIM="$(echo $RANDOM | base64 | head -c 3; echo)" | |
echo "tags-file=$PWD/tag-publishing" >> $GITHUB_OUTPUT | |
echo "tags-string<<$DELIM" >> $GITHUB_OUTPUT | |
echo "$(cat $PWD/tag-publishing)" >> $GITHUB_OUTPUT | |
echo "$DELIM" >> $GITHUB_OUTPUT | |
echo "git-output=$GITHUB_OUTPUT" >> $GITHUB_OUTPUT | |
- | |
name: Upload versioning and caching hcl as artifacts | |
uses: actions/[email protected] | |
with: | |
name: HCL artifacts | |
path: | | |
${{ steps.local-versioning.outputs.bake-file }} | |
${{ steps.dockerhub-tags.outputs.tags-file }} | |
${{ steps.dockerhub-tags.outputs.git-output }} | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: v0.11.0 | |
driver-opts: | | |
image=moby/buildkit:v0.11.6 | |
- | |
name: Build container | |
id: container-build | |
uses: docker/[email protected] | |
with: | |
targets: | | |
${{ inputs.target }} | |
files: | | |
${{ steps.local-versioning.outputs.bake-file }} | |
./versioning.hcl | |
./docker-bake.hcl | |
set: ${{ steps.dockerhub-tags.outputs.tags-string }} | |
push: true | |
- | |
name: Save output container metadata to file | |
id: container-metadata | |
run: | | |
echo "${{ steps.container-build.outputs.metadata }}" >> container-metadata.json | |
echo "metadata=$PWD/container-metadata.json" >> $GITHUB_OUTPUT | |
- | |
name: Upload bake definition | |
uses: actions/[email protected] | |
with: | |
name: Baking artifacts | |
path: | | |
${{ steps.container-metadata.outputs.metadata }} |