diff --git a/.github/workflows/docker-build-image.yml b/.github/workflows/docker-build-image.yml new file mode 100644 index 0000000000..8481d4308c --- /dev/null +++ b/.github/workflows/docker-build-image.yml @@ -0,0 +1,138 @@ +name: build-image + +on: + workflow_call: + inputs: + image-name: + required: true + type: string + build-context: + required: true + type: string + dockerfile: + required: true + type: string + r-version: + required: true + type: string + parent-image: + required: false + default: '' + type: string + model-version: + required: false + default: '' + type: string + platforms: + required: false + default: "linux/amd64" + type: string + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + + steps: + + - name: lowercase image name + id: name + run: echo "image_name=$(echo ${{ inputs.image-name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT + + - name: set PARENT_IMAGE only if specified + id: parent + shell: bash + run: | + REGISTRY=$( + [[ ${{ github.event_name }} == 'pull_request' ]] && + echo "ghcr.io/${{ github.actor }}/${{ github.repository }}" || + echo "docker.io/pecan") + echo "PARENT_IMAGE_IF_SET=$( + [[ -n '${{ inputs.parent-image }}' ]] && + echo "PARENT_IMAGE=${REGISTRY}/"'${{ inputs.parent-image }}' + )" >> $GITHUB_OUTPUT + + - name: set MODEL_VERSION only if specified + id: modelver + shell: bash + run: | + echo "MODEL_VERSION_IF_SET=$( + [[ -n '${{ inputs.model-version }}' ]] && + echo 'MODEL_VERSION=${{ inputs.model-version }}' + )" >> $GITHUB_OUTPUT + + - uses: actions/checkout@v4 + + # create metadata for image + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + name=ghcr.io/${{ github.actor }}/${{ github.repository }}/${{ steps.name.outputs.image_name }} + name=pecan/${{ steps.name.outputs.image_name }},enable=${{ github.event_name != 'pull_request' }} + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + # setup docker build + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Inspect Builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + + # login to registries + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # build the docker images + - name: Build and push ${{ steps.name.outputs.image_name }} + uses: docker/build-push-action@v6 + with: + context: ${{ inputs.build-context }} + file: ${{ inputs.dockerfile }} + push: true + platforms: ${{ inputs.platforms }} + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ steps.meta.outputs.version }} + IMAGE_VERSION=${{ steps.meta.outputs.version }} + PECAN_VERSION=${{ steps.meta.outputs.version }} + R_VERSION=${{ inputs.r-version }} + ${{ steps.parent.outputs.PARENT_IMAGE_IF_SET }} + ${{ steps.modelver.outputs.MODEL_VERSION_IF_SET }} + GITHUB_PAT=${{ secrets.GITHUB_TOKEN }} + PECAN_GIT_BRANCH=${{ github.head_ref || github.ref_name }} + PECAN_GIT_CHECKSUM=${{ github.sha }} + PECAN_GIT_DATE=${{ github.event.repository.updated_at }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 807e621f5d..18b01deaae 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,262 +23,72 @@ on: - 4.4 - devel -# set up the environment, either input or default -env: - R_VERSION: ${{ github.event.inputs.r_version || '4.1' }} -# there are 3 jobs to build different images 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..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: - runs-on: ubuntu-latest permissions: packages: write - - steps: - - uses: actions/checkout@v4 - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - pecan/depends - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/depends - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # build the docker images - - name: Build and push depends - uses: docker/build-push-action@v6 - with: - context: docker/depends - file: docker/depends/Dockerfile - push: true - platforms: "linux/amd64" - cache-from: type=registry,ref=pecan/depends:buildcache - cache-to: type=registry,ref=pecan/depends:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} - GITHUB_PAT=${{ secrets.GITHUB_TOKEN }} + 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: - runs-on: ubuntu-latest - needs: depends - permissions: - packages: write - - steps: - - uses: actions/checkout@v4 - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - pecan/base - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/base - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # build the docker images - - name: Build and push base - uses: docker/build-push-action@v6 - with: - context: . - file: docker/base/Dockerfile - push: true - platforms: "linux/amd64" - cache-from: type=registry,ref=pecan/base:buildcache - cache-to: type=registry,ref=pecan/base:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} - FROM_IMAGE=depends - IMAGE_VERSION=${{ steps.meta.outputs.version }} - GITHUB_PAT=${{ secrets.GITHUB_TOKEN }} - PECAN_VERSION=${{ steps.meta.outputs.version }} - PECAN_GIT_BRANCH= ${{ github.head_ref || github.ref_name }} - PECAN_GIT_CHECKSUM=${{ github.sha }} - PECAN_GIT_DATE=${{ github.event.repository.updated_at }} + 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: "depends" + platforms: "linux/amd64" + secrets: inherit # ---------------------------------------------------------------------- # models image has some python installed to run models, depends on base # ---------------------------------------------------------------------- models: - runs-on: ubuntu-latest - needs: base - permissions: - packages: write - - steps: - - uses: actions/checkout@v4 - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as models name for tags - images: | - pecan/models - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/models - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # build the docker images - - name: Build and push models - uses: docker/build-push-action@v6 - with: - context: docker/models - file: docker/models/Dockerfile - push: true - platforms: "linux/amd64" - cache-from: type=registry,ref=pecan/models:buildcache - cache-to: type=registry,ref=pecan/models:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} - FROM_IMAGE=depends - IMAGE_VERSION=${{ steps.meta.outputs.version }} - GITHUB_PAT=${{ secrets.GITHUB_TOKEN }} - PECAN_VERSION=${{ steps.meta.outputs.version }} - PECAN_GIT_BRANCH= ${{ github.head_ref || github.ref_name }} - PECAN_GIT_CHECKSUM=${{ github.sha }} - PECAN_GIT_DATE=${{ github.event.repository.updated_at }} + 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: "base" + secrets: inherit # ---------------------------------------------------------------------- # Next are images that have models installed # ---------------------------------------------------------------------- modelsbinary: - runs-on: ubuntu-latest - needs: models - permissions: - packages: write + needs: [rversion, models] strategy: fail-fast: false matrix: @@ -326,92 +136,22 @@ jobs: PLATFORM: "linux/amd64" MODEL: sipnet VERSION: "git" - - steps: - - uses: actions/checkout@v4 - - # lower case name for docker - - name: docker image name - id: lower - run: echo "image_name=$(echo model-${{ matrix.MODEL }}-${{ matrix.VERSION }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - pecan/${{ steps.lower.outputs.image_name }} - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/${{ steps.lower.outputs.image_name }} - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: docker image ls - run: docker image ls - - # build the docker images - - name: Build and push ${{ matrix.MODEL }} ${{ matrix.VERSION }} - uses: docker/build-push-action@v6 - with: - context: ${{ matrix.CONTEXT }} - file: ${{ matrix.DOCKERFILE }} - push: true - platforms: ${{ matrix.PLATFORM }} - cache-from: type=registry,ref=pecan/${{ steps.lower.outputs.image_name }}:buildcache - cache-to: type=registry,ref=pecan/${{ steps.lower.outputs.image_name }}:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} - MODEL_VERSION=${{ matrix.VERSION }} - IMAGE_VERSION=${{ steps.meta.outputs.version }} + 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: "models" + model-version: ${{ matrix.VERSION }} + platforms: ${{ matrix.PLATFORM }} + secrets: inherit # ---------------------------------------------------------------------- # Next are images that depend on base image # ---------------------------------------------------------------------- baseplus: - runs-on: ubuntu-latest - needs: base - permissions: - packages: write + needs: [rversion, base] strategy: fail-fast: false matrix: @@ -424,99 +164,34 @@ jobs: CONTEXT: . DOCKERFILE: docker/docs/Dockerfile PLATFORM: "linux/amd64" - IMAGE: docs - name: executor CONTEXT: docker/executor DOCKERFILE: docker/executor/Dockerfile PLATFORM: "linux/amd64" - IMAGE: executor - name: api CONTEXT: apps/api DOCKERFILE: apps/api/Dockerfile PLATFORM: "linux/amd64" - IMAGE: api - - steps: - - uses: actions/checkout@v4 - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - pecan/${{ matrix.IMAGE }} - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/${{ matrix.IMAGE }} - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # build the docker images - - name: Build and push ${{ matrix.name }} - uses: docker/build-push-action@v6 - with: - context: ${{ matrix.CONTEXT }} - file: ${{ matrix.DOCKERFILE }} - push: true - platforms: ${{ matrix.PLATFORM }} - cache-from: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache - cache-to: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} - IMAGE_VERSION=${{ steps.meta.outputs.version }} + 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: - runs-on: ubuntu-latest - permissions: - packages: write + needs: rversion strategy: fail-fast: false matrix: name: - web - - dbsync + - shiny-dbsync - data - monitor - rstudio-nginx @@ -525,91 +200,26 @@ jobs: CONTEXT: . DOCKERFILE: docker/web/Dockerfile PLATFORM: "linux/amd64,linux/arm64" - IMAGE: web - - name: dbsync + - name: shiny-dbsync CONTEXT: . DOCKERFILE: shiny/dbsync/Dockerfile PLATFORM: "linux/amd64" - IMAGE: shiny-dbsync - name: data CONTEXT: docker/data DOCKERFILE: docker/data/Dockerfile PLATFORM: "linux/amd64,linux/arm64" - IMAGE: data - name: monitor CONTEXT: docker/monitor DOCKERFILE: docker/monitor/Dockerfile PLATFORM: "linux/amd64,linux/arm64" - IMAGE: monitor - name: rstudio-nginx CONTEXT: docker/rstudio-nginx DOCKERFILE: docker/rstudio-nginx/Dockerfile PLATFORM: "linux/amd64,linux/arm64" - IMAGE: rstudio-nginx - - steps: - - uses: actions/checkout@v4 - - # create metadata for image - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - # list of Docker images to use as base name for tags - images: | - pecan/${{ matrix.IMAGE }} - ghcr.io/${{ github.repository_owner }}/${{ github.repository }}/${{ matrix.IMAGE }} - # generate Docker tags based on the following events/attributes - tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - # setup docker build - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Inspect Builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - # login to registries - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # build the docker images - - name: Build and push ${{ matrix.name }} - uses: docker/build-push-action@v6 - with: - context: ${{ matrix.CONTEXT }} - file: ${{ matrix.DOCKERFILE }} - push: true - platforms: ${{ matrix.PLATFORM }} - cache-from: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache - cache-to: type=registry,ref=pecan/${{ matrix.IMAGE }}:buildcache,mode=max - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - VERSION=${{ steps.meta.outputs.version }} - R_VERSION=${{ env.R_VERSION }} + 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 }} diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 059e14f0c0..0a8e3acab6 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -1,11 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" - +ARG PARENT_IMAGE="pecan/base" # -------------------------------------------------------------------------- # PECAN FOR MODEL BASE IMAGE # -------------------------------------------------------------------------- -FROM pecan/base:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} EXPOSE 8000 diff --git a/docker.sh b/docker.sh index 4a2e335399..99fdc34c3f 100755 --- a/docker.sh +++ b/docker.sh @@ -69,7 +69,7 @@ To set the version used of R when building the dependency image use the environment option R_VERSION (as well as DEPEND). You can also use the -r option which will make sure the dependency image is build. -You can use the FROM_IMAGE environment variable to also specify what +You can use the PARENT_IMAGE environment variable to also specify what image should be used when building the base image. You can for example use the previous base image which will speed up the compile process of PEcAn. @@ -135,7 +135,7 @@ elif [ "${UPDATE_DEPENDS_FROM_TAG}" != "" ]; then ${DEBUG} docker build \ --pull \ --secret id=github_token,env=GITHUB_PAT \ - --build-arg FROM_IMAGE="pecan/depends" \ + --build-arg PARENT_IMAGE="pecan/depends" \ --build-arg R_VERSION=${UPDATE_DEPENDS_FROM_TAG} ${GITHUB_WORKFLOW_ARG} \ --tag pecan/depends:${IMAGE_VERSION} \ docker/depends @@ -163,7 +163,7 @@ for x in base web docs; do ${DEBUG} docker build \ --secret id=github_token,env=GITHUB_PAT \ --tag pecan/$x:${IMAGE_VERSION} \ - --build-arg FROM_IMAGE="${FROM_IMAGE:-depends}" \ + --build-arg PARENT_IMAGE="${PARENT_IMAGE:-depends}" \ --build-arg IMAGE_VERSION="${IMAGE_VERSION}" ${GITHUB_WORKFLOW_ARG} \ --build-arg PECAN_VERSION="${VERSION}" \ --build-arg PECAN_GIT_BRANCH="${PECAN_GIT_BRANCH}" \ diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index abbffd47c9..19a2692ef2 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -1,7 +1,7 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" -ARG FROM_IMAGE="depends" -FROM pecan/${FROM_IMAGE}:${IMAGE_VERSION} +ARG PARENT_IMAGE="pecan/depends" +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # PEcAn version information diff --git a/docker/depends/Dockerfile b/docker/depends/Dockerfile index b784bcd3bf..03b990d501 100644 --- a/docker/depends/Dockerfile +++ b/docker/depends/Dockerfile @@ -1,10 +1,10 @@ ARG R_VERSION="4.1" -ARG FROM_IMAGE="rocker/tidyverse" +ARG PARENT_IMAGE="rocker/tidyverse" # ---------------------------------------------------------------------- # PECAN FOR MODEL BASE IMAGE # ---------------------------------------------------------------------- -FROM ${FROM_IMAGE}:${R_VERSION} +FROM ${PARENT_IMAGE}:${R_VERSION} # ---------------------------------------------------------------------- # INSTALL BINARY/LIBRARY DEPENDENCIES diff --git a/docker/docs/Dockerfile b/docker/docs/Dockerfile index 315769eed5..10a0aaa99b 100644 --- a/docker/docs/Dockerfile +++ b/docker/docs/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/base" # ---------------------------------------------------------------------- # compile bookdown to html # ---------------------------------------------------------------------- -FROM pecan/base:${IMAGE_VERSION} AS pecandocs +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} AS pecandocs RUN apt-get update \ && apt-get install -y --no-install-recommends pandoc \ diff --git a/docker/executor/Dockerfile b/docker/executor/Dockerfile index 19cecced3c..7181eebdd3 100644 --- a/docker/executor/Dockerfile +++ b/docker/executor/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/base" # ---------------------------------------------------------------------- # PECAN FOR MODEL BASE IMAGE # ---------------------------------------------------------------------- -FROM pecan/base:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # SETUP FOR PYTHON CODE diff --git a/docker/models/Dockerfile b/docker/models/Dockerfile index f76f51382e..02a1c16f99 100644 --- a/docker/models/Dockerfile +++ b/docker/models/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/base" # ---------------------------------------------------------------------- # PECAN FOR MODEL BASE IMAGE # ---------------------------------------------------------------------- -FROM pecan/base:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # SETUP FOR PYTHON CODE diff --git a/models/basgra/Dockerfile b/models/basgra/Dockerfile index d9c382fa5f..65b348e3ea 100644 --- a/models/basgra/Dockerfile +++ b/models/basgra/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD PECAN FOR BASGRA # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # SETUP FOR SPECIFIC BASGRA VERSION diff --git a/models/biocro/Dockerfile b/models/biocro/Dockerfile index abf63f5d62..163afd2a09 100644 --- a/models/biocro/Dockerfile +++ b/models/biocro/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD PECAN FOR BIOCRO # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # SETUP FOR SPECIFIC BIOCRO VERSION diff --git a/models/ed/Dockerfile b/models/ed/Dockerfile index a3873e896a..e5af7b500a 100644 --- a/models/ed/Dockerfile +++ b/models/ed/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD MODEL BINARY # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} AS model-binary +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} AS model-binary # Some variables that can be used to set control the docker build ARG MODEL_VERSION="2.2.0" @@ -34,7 +35,7 @@ RUN cd ED2/ED/build \ # ---------------------------------------------------------------------- # BUILD PECAN FOR MODEL # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # INSTALL MODEL SPECIFIC PIECES diff --git a/models/maespa/Dockerfile b/models/maespa/Dockerfile index 22243dc3c1..ee4c438050 100644 --- a/models/maespa/Dockerfile +++ b/models/maespa/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD MODEL BINARY # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} AS model-binary +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} AS model-binary # download, unzip and build ed2 WORKDIR /src @@ -17,7 +18,7 @@ RUN git -c http.sslVerify=false clone https://bitbucket.org/remkoduursma/maespa. # ---------------------------------------------------------------------- # BUILD PECAN FOR MODEL # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # INSTALL MODEL SPECIFIC PIECES diff --git a/models/sipnet/Dockerfile b/models/sipnet/Dockerfile index d69e845dd4..909bb49ec6 100644 --- a/models/sipnet/Dockerfile +++ b/models/sipnet/Dockerfile @@ -1,10 +1,11 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD SIPNET BINARY # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} AS model-binary +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} AS model-binary # Some variables that can be used to set control the docker build ARG MODEL_VERSION=git @@ -21,7 +22,7 @@ RUN git clone https://github.com/PecanProject/sipnet.git \ # ---------------------------------------------------------------------- # BUILD PECAN FOR SIPNET # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # INSTALL SIPNET SPECIFIC PIECES diff --git a/models/template/Dockerfile b/models/template/Dockerfile index 00b5e65f52..4d025f3000 100644 --- a/models/template/Dockerfile +++ b/models/template/Dockerfile @@ -6,11 +6,12 @@ # this needs to be at the top, what version are we building ARG IMAGE_VERSION="latest" +ARG PARENT_IMAGE="pecan/models" # ---------------------------------------------------------------------- # BUILD MODEL BINARY # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} as model-binary +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} as model-binary # Some variables that can be used to set control the docker build ARG MODEL_VERSION=git @@ -35,7 +36,7 @@ RUN git clone https://github.com/model/repo.git \ # ---------------------------------------------------------------------- # BUILD PECAN FOR MODEL # ---------------------------------------------------------------------- -FROM pecan/models:${IMAGE_VERSION} +FROM ${PARENT_IMAGE}:${IMAGE_VERSION} # ---------------------------------------------------------------------- # INSTALL MODEL SPECIFIC PIECES