diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml new file mode 100644 index 0000000..0e1dbf9 --- /dev/null +++ b/.github/workflows/manual-build.yml @@ -0,0 +1,104 @@ +name: Manual Build from Branch + +env: + GITHUB_SHA: ${{ github.sha }} + IMAGE_ROOT: singleuser + REGISTRY_HOSTNAME: docker.io + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }} + +on: + workflow_dispatch: + inputs: + code-branch: + description: 'Code branch to build from' + required: true + default: develop + image: + type: choice + description: 'Image Name' + required: true + default: 'base' + options: + - base + - base-py37 + - base-centos7 + - scientific-py3 + - scientific-r + - hydrogeology-r + - waterhackweek + - geophysics + - parflow + - summa-py3 + - wrfhydro + - csdms-tools + - modflow + - hl-physical-hydrology + - test + push-to-dockerhub: + description: Push to Repository + type: boolean + required: true + default: false + +jobs: + build-image: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ inputs.code-branch }} + + - name: Load .env file + uses: xom9ikk/dotenv@v2 + with: + path: ${{ env.IMAGE_ROOT }} + + - name: Docker Login + run: | + echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin + + # Build the Docker image + - name: Echo Info + id: info + run: | + echo "Building Image for:" + echo " Branch = ${{ inputs.code-branch }}" + echo " Image = ${{ inputs.image }}" + echo ------------ + echo "JH_BASE: ${{ env.JH_BASE }}" + echo "CUAHSI_BASE: ${{ env.CUAHSI_BASE }}" + echo "BUILD_DATE: ${{ env.BUILD_DATE }}" + echo ------------ + - name: Build + run: | + cd "${IMAGE_ROOT}" + docker compose build ${{ inputs.image }} + - name: Push Docker Image + if: ${{ inputs.push-to-dockerhub }} + run: | + echo "Begin Image Tagging and Pushing" + + # use BUILD_DATE in the tag + # unless we're building the 'base' image + if [ ${{ inputs.image }} == "base" ]; then + export DOCKER_TAG="${REPOSITORY}/${IMAGE_ROOT}-${{ inputs.image }}:${{ env.CUAHSI_BASE }}" + else + export DOCKER_TAG="${REPOSITORY}/${IMAGE_ROOT}-${{ inputs.image }}:${{ env.BUILD_DATE }}" + fi + + export DOCKER_FULL_PATH="${REPOSITORY}/${IMAGE_ROOT}-${{ inputs.image }}:${{ inputs.code-branch }}-latest" + echo "Old Image Name/Tag = $DOCKER_TAG" + echo "New Image Name/Tag = $DOCKER_FULL_PATH" + + echo "DOCKER_FULL_PATH=$DOCKER_FULL_PATH" >> $GITHUB_ENV + + + docker tag $DOCKER_TAG $DOCKER_FULL_PATH + docker push $DOCKER_FULL_PATH + + echo "End Image Tagging and Pushing" + diff --git a/.github/workflows/periodic-image-build.yml b/.github/workflows/periodic-image-build.yml index 8290856..44e3057 100644 --- a/.github/workflows/periodic-image-build.yml +++ b/.github/workflows/periodic-image-build.yml @@ -24,11 +24,11 @@ jobs: matrix: IMAGE_VARIANT: - base - - scientific - - r - - summa + - scientific-py3 + - scientific-r + - summa-py3 - wrfhydro - - csdms + - csdms-tools steps: - name: Checkout uses: actions/checkout@v2 @@ -44,32 +44,11 @@ jobs: uses: xom9ikk/dotenv@v2 with: path: ${{ env.IMAGE_ROOT }} - - - name: Docker Login - run: | - echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USER --password-stdin # Build the Docker image - name: Build run: | cd "${IMAGE_ROOT}" docker compose build ${{ matrix.IMAGE_VARIANT }} - - - name: Echo env configuration and set image tag - id: tagging - run: | - echo "JH_BASE: ${{ env.JH_BASE }}" - echo "CUAHSI_BASE: ${{ env.CUAHSI_BASE }}" - echo "BUILD_DATE: ${{ env.BUILD_DATE }}" - echo ------------ - export DOCKER_TAG="${REPOSITORY}/${IMAGE_ROOT}-${{ matrix.IMAGE_VARIANT }}:${{ env.CUAHSI_BASE }}" - export DOCKER_FULL_PATH="$DOCKER_TAG-periodic-$(date +'%Y.%m.%d')" - echo "DOCKER_FULL_PATH=$DOCKER_FULL_PATH" >> $GITHUB_ENV - echo $DOCKER_FULL_PATH - docker tag $DOCKER_TAG $DOCKER_FULL_PATH - - - name: Push Docker Image - run: | - docker push $DOCKER_FULL_PATH # TODO: run tests? diff --git a/.github/workflows/trigger-build-on-changes.yml b/.github/workflows/trigger-build-on-changes.yml index 27a17e6..1fed964 100644 --- a/.github/workflows/trigger-build-on-changes.yml +++ b/.github/workflows/trigger-build-on-changes.yml @@ -7,6 +7,7 @@ env: DOCKER_USER: ${{ secrets.DOCKER_USER }} DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} REPOSITORY: ${{ secrets.DOCKER_REPOSITORY }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} on: push: @@ -27,11 +28,11 @@ jobs: with: filters: | base: ${{ env.IMAGE_ROOT }}/base/** - scientific: ${{ env.IMAGE_ROOT }}/python3-scientific/** - r: ${{ env.IMAGE_ROOT }}/r/** - summa: ${{ env.IMAGE_ROOT }}/python3-summa/** + scientific-py3: ${{ env.IMAGE_ROOT }}/python3-scientific/** + scientific-r: ${{ env.IMAGE_ROOT }}/r/** + summa-py3: ${{ env.IMAGE_ROOT }}/python3-summa/** wrfhydro: ${{ env.IMAGE_ROOT }}/python3-wrfhydro/** - csdms: ${{ env.IMAGE_ROOT }}/csdms-tools/** + csdms-tools: ${{ env.IMAGE_ROOT }}/csdms-tools/** setup-build-publish-deploy: needs: detect-changes name: Setup, Build, and Publish @@ -63,12 +64,15 @@ jobs: - name: Echo env configuration and set image tag id: tagging run: | + echo "IMAGE_VARIANT: ${{ matrix.IMAGE_VARIANT }}" echo "JH_BASE: ${{ env.JH_BASE }}" echo "CUAHSI_BASE: ${{ env.CUAHSI_BASE }}" echo "BUILD_DATE: ${{ env.BUILD_DATE }}" + echo "GITHUB_SHA: $GITHUB_SHA" + echo "BRANCH_NAME: $BRANCH_NAME" echo ------------ export DOCKER_TAG="${REPOSITORY}/${IMAGE_ROOT}-${{ matrix.IMAGE_VARIANT }}:${{ env.CUAHSI_BASE }}" - export DOCKER_FULL_PATH="$DOCKER_TAG-$GITHUB_SHA" + export DOCKER_FULL_PATH="${REPOSITORY}/${IMAGE_ROOT}:$BRANCH_NAME-latest" echo "DOCKER_FULL_PATH=$DOCKER_FULL_PATH" >> $GITHUB_ENV echo $DOCKER_FULL_PATH docker tag $DOCKER_TAG $DOCKER_FULL_PATH diff --git a/singleuser/docker-compose.yml b/singleuser/docker-compose.yml index 5c03637..ce73489 100644 --- a/singleuser/docker-compose.yml +++ b/singleuser/docker-compose.yml @@ -21,7 +21,7 @@ services: ################### # Base Python 3.7 # ################### - base-py37: + base-py3.7: env_file: - '.env' build: @@ -64,7 +64,7 @@ services: labels: description: | CUAHSI JupyterHub singleuser environment configured with scientific libraries. Built using cuahsi/jupyterhub-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-scientific-py3:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-scientific-py3:${CUAHSI_BASE} ################## # Scientific - R # @@ -81,7 +81,7 @@ services: labels: description: | CUAHSI JupyterHub singleuser environment configured with scientific libraries with the R programming language. Built using cuahsi/jupyterhub-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-scientific-r:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-scientific-r:${CUAHSI_BASE} ############################## # 2020 Hydrogeology Syracuse # @@ -97,7 +97,7 @@ services: labels: description: | CUAHSI JupyterHub singleuser environment configured with scientific libraries for Tao Wen's 2020 Hydrogeology course at Syracuse University. Built using cuahsi/singleuser-scientific-r:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-hydrogeology-r:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-hydrogeology-r:${CUAHSI_BASE} ###################### # 2020 WHW - Seattle # @@ -113,7 +113,7 @@ services: labels: description: | This environment is configured with scientific libraries for the 2020 Waterhackweek Cybertraining event. Built using cuahsi/singleuser-scientific-py3:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-waterhackweek:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-waterhackweek:${CUAHSI_BASE} ################################ # 2018 Near Surface Geophysics # @@ -130,7 +130,7 @@ services: labels: description: | CUAHSI JupyterHub singleuser environment configured for the 2019 Near Surface Geophysics Workshop. This image uses WINE to run R2, gmsh,and pyres. Built using cuahsi/singleuser-scientific-py3:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-geophysics:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-geophysics:${CUAHSI_BASE} #################### @@ -165,7 +165,7 @@ services: labels: description: | Environment configured for Parflow. Built using cuahsi/singleuser-base:centos7.v${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-parflow:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-parflow:${CUAHSI_BASE} ######### # SUMMA # @@ -182,7 +182,7 @@ services: labels: description: | Environment configured for SUMMA. Built using cuahsi/singleuser-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-summa-py3:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-summa-py3:${CUAHSI_BASE} ############### # CSDMS TOOLS # @@ -199,7 +199,7 @@ services: labels: description: | Environment configured for the Community Surface Dynamics Modeling System. Built using cuahsi/singleuser-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-csdms-tools:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-csdms-tools:${CUAHSI_BASE} ############# # WRF-Hydro # @@ -220,7 +220,7 @@ services: labels: description: | Environment configured for the NCAR WRF-Hydro model (nwm v2.0). Built using cuahsi/singleuser-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-wrfhydro:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-wrfhydro:${CUAHSI_BASE} ############# # SI-2021 # @@ -237,7 +237,7 @@ services: labels: description: | Environment configured for the 2021 SI. Built using cuahsi/singleuser-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-si2021:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-si2021:${CUAHSI_BASE} ############# # MODFLOW # @@ -254,7 +254,7 @@ services: labels: description: | Environment configured to run MODFLOW for the 2021 IAH conference. Built using cuahsi/singleuser-base:${CUAHSI_BASE} on ${BUILD_DATE}. - image: ${REPOSITORY}/singleuser-modflow:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-modflow:${CUAHSI_BASE} ################### # EDU - Gerbrand # @@ -268,7 +268,7 @@ services: args: # image version to use as base BASE_VERSION: ${CUAHSI_BASE} - image: cuahsi/singleuser-edu:${BUILD_DATE} + image: ${REPOSITORY}/singleuser-edu:${CUAHSI_BASE} #################################### # HydroLearn - Physical Hydrology #