Skip to content

Callable workflow for Docker image build #6031

Callable workflow for Docker image build

Callable workflow for Docker image build #6031

Workflow file for this run

name: Docker GHA
on:
push:
branches:
- main
- develop
tags:
- "v*.*.*"
pull_request:
merge_group:
workflow_dispatch:
inputs:
r_version:
description: 'R version to use'
required: true
type: choice
default: "4.1"
options:
- 4.1
- 4.2
- 4.3
- 4.4
- devel
jobs:
# ----------------------------------------------------------------------
# Set R version.
# This is a hack: We really just want a global env var here, but it seems
# `env:` values can't be passed into a `jobs.<jobid>.with` context
# (see https://github.com/actions/runner/issues/2372).
# As an ugly workaround, we assign it to a job output instead.
# ----------------------------------------------------------------------
rversion:
runs-on: ubuntu-latest
steps:
- run: echo "null"
outputs:
R_VERSION: ${{ github.event.inputs.r_version || '4.1' }}
# ----------------------------------------------------------------------
# depends image has all the dependencies installed
# ----------------------------------------------------------------------
depends:
permissions:
packages: write
needs: rversion
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: depends
build-context: docker/depends
dockerfile: docker/depends/Dockerfile
r-version: ${{ needs.rversion.outputs.R_VERSION }}
platforms: "linux/amd64"
secrets: inherit
# ----------------------------------------------------------------------
# base image has PEcAn compiled and installed, and depends on depends
# ----------------------------------------------------------------------
base:
needs: [rversion, depends]
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: base
build-context: .
dockerfile: docker/base/Dockerfile
r-version: ${{ needs.rversion.outputs.R_VERSION }}
parent-image: "pecan/depends"
platforms: "linux/amd64"
secrets: inherit
# ----------------------------------------------------------------------
# models image has some python installed to run models, depends on base
# ----------------------------------------------------------------------
models:
needs: [rversion, base]
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: models
build-context: docker/models
dockerfile: docker/models/Dockerfile
r-version: ${{ needs.rversion.outputs.R_VERSION }}
parent-image: "pecan/base"
secrets: inherit
# ----------------------------------------------------------------------
# Next are images that have models installed
# ----------------------------------------------------------------------
modelsbinary:
needs: [rversion, models]
strategy:
fail-fast: false
matrix:
name:
- basgra
- biocro
# - ed2_2.2.0
- ed2_git
- maespa
- sipnet
include:
- name: basgra
CONTEXT: models/basgra
DOCKERFILE: models/basgra/Dockerfile
PLATFORM: "linux/amd64"
MODEL: basgra
VERSION: BASGRA_N_v1
- name: biocro
CONTEXT: models/biocro
DOCKERFILE: models/biocro/Dockerfile
PLATFORM: "linux/amd64"
MODEL: biocro
VERSION: "0.95"
# - name: ed2_2.2.0
# CONTEXT: models/ed
# DOCKERFILE: models/ed/Dockerfile
# PLATFORM: "linux/amd64"
# MODEL: ed2
# VERSION: "2.2.0"
- name: ed2_git
CONTEXT: models/ed
DOCKERFILE: models/ed/Dockerfile
PLATFORM: "linux/amd64"
MODEL: ed2
VERSION: "git"
- name: maespa
CONTEXT: models/maespa
DOCKERFILE: models/maespa/Dockerfile
PLATFORM: "linux/amd64"
MODEL: maespa
VERSION: "git"
- name: sipnet
CONTEXT: models/sipnet
DOCKERFILE: models/sipnet/Dockerfile
PLATFORM: "linux/amd64"
MODEL: sipnet
VERSION: "git"
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: model-${{ matrix.MODEL }}-${{ matrix.VERSION }}
build-context: ${{ matrix.CONTEXT }}
dockerfile: ${{ matrix.DOCKERFILE }}
r-version: ${{ needs.rversion.outputs.R_VERSION }}
parent-image: "pecan/models"
model-version: ${{ matrix.VERSION }}
platforms: ${{ matrix.PLATFORM }}
secrets: inherit
# ----------------------------------------------------------------------
# Next are images that depend on base image
# ----------------------------------------------------------------------
baseplus:
needs: [rversion, base]
strategy:
fail-fast: false
matrix:
name:
- docs
- executor
- api
include:
- name: docs
CONTEXT: .
DOCKERFILE: docker/docs/Dockerfile
PLATFORM: "linux/amd64"
- name: executor
CONTEXT: docker/executor
DOCKERFILE: docker/executor/Dockerfile
PLATFORM: "linux/amd64"
- name: api
CONTEXT: apps/api
DOCKERFILE: apps/api/Dockerfile
PLATFORM: "linux/amd64"
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: ${{ matrix.name }}
build-context: ${{ matrix.CONTEXT }}
dockerfile: ${{ matrix.DOCKERFILE }}
r-version: ${{ needs.rversion.outputs.R_VERSION }}
platforms: ${{ matrix.PLATFORM }}
secrets: inherit
# ----------------------------------------------------------------------
# Next are images that do not depend on either depends or base image
# ----------------------------------------------------------------------
extras:
needs: rversion
strategy:
fail-fast: false
matrix:
name:
- web
- shiny-dbsync
- data
- monitor
- rstudio-nginx
include:
- name: web
CONTEXT: .
DOCKERFILE: docker/web/Dockerfile
PLATFORM: "linux/amd64,linux/arm64"
- name: shiny-dbsync
CONTEXT: .
DOCKERFILE: shiny/dbsync/Dockerfile
PLATFORM: "linux/amd64"
- name: data
CONTEXT: docker/data
DOCKERFILE: docker/data/Dockerfile
PLATFORM: "linux/amd64,linux/arm64"
- name: monitor
CONTEXT: docker/monitor
DOCKERFILE: docker/monitor/Dockerfile
PLATFORM: "linux/amd64,linux/arm64"
- name: rstudio-nginx
CONTEXT: docker/rstudio-nginx
DOCKERFILE: docker/rstudio-nginx/Dockerfile
PLATFORM: "linux/amd64,linux/arm64"
uses: ./.github/workflows/docker-build-image.yml
with:
image-name: ${{ matrix.name }}
build-context: ${{ matrix.CONTEXT }}
dockerfile: ${{ matrix.DOCKERFILE }}
platforms: ${{ matrix.PLATFORM }}
r-version: ${{ needs.rversion.outputs.R_VERSION }}