Skip to content

Commit

Permalink
added test branch to trigger
Browse files Browse the repository at this point in the history
fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix

fix
  • Loading branch information
marjo-luc committed Oct 23, 2024
1 parent e484312 commit e52cc08
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 15 deletions.
88 changes: 77 additions & 11 deletions .github/workflows/build-ogc-app-pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,94 @@
# Steps:
#
# 1. Parse the input algorithm config to retrieve the build parameters.
# 2. Build OGC application package executable (docker image).
# 3. Generate the application package process cwl.
# 4. Push the OGC application package executable to the image registry.
# 2. Generate the application package process cwl.
# 3. Build and publish the algorithm Docker image to GitLab
# 4. Build and publish the OGC application package to GitLab
on:
push:
branches:
- main
- feature/app-pack-gen

jobs:
build_ogc_app_pack:
environment: DIT
runs-on: ubuntu-latest
steps:
- name: Checkout repo content
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: 3.9

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip list
- name: Generate build config for algorithm
run: python3 generate_build_config.py algorithm_configs/algorithm_config.yaml

- name: Source build config environment variables
run: echo ${{ github.workspace }}
run: source ${{ github.workspace }}/config.txt
- name: Build OGC application package executable
run: docker build -t ${{REPO_NAME}}:${{BRANCH}} -f docker/Dockerfile .
- name: Build OGC application package process cwl
run: python3 generate_app_pack.py algorithm_configs/algorithm_config.yaml $(basename ${ogc_container_url})
- name: Push OGC application package executable to image registry
run: echo Push to image registry not yet implemented.
uses: c-py/action-dotenv-to-setenv@v5
with:
env-file: .env

- name: Log in to GitHub CR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to GitLab CR
uses: docker/login-action@v3
with:
registry: ${{ vars.GITLAB_CONTAINER_REGISTRY }}
username: ${{ vars.GITLAB_USERNAME }}
password: ${{ secrets.OGC_APP_PACK_GEN_CI_GH_ACTION_TOKEN }}

- name: Generate OGC application package process cwl
run: python3 generate_app_pack.py algorithm_configs/algorithm_config.yaml ${{ env.REPO_NAME }}:${{ env.BRANCH }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ vars.GITLAB_CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}
tags: algorithm

- name: Build and push algorithm Docker image
id: push-algorithm
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.algorithm
build-args: |
BASE_IMAGE_NAME=${{ env.BASE_IMAGE_NAME }}
REPO_NAME=${{ env.REPO_NAME }}
BRANCH=${{ env.BRANCH }}
REPO_URL_WITH_TOKEN=${{ env.REPO_URL_WITH_TOKEN }}
BUILD_CMD=${{ env.BUILD_CMD }}
push: true
tags: ${{ vars.GITLAB_CONTAINER_REGISTRY }}/${{ env.ALGORITHM_NAME }}.${{ env.BRANCH }}:latest
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push OGC application package Docker image
id: push-ogc_app_pack
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile.ogc
build-args: |
PROCESS_CWL=${{ env.ALGORITHM_NAME }}.${{ env.BRANCH }}.process.cwl
push: true
tags: ${{ vars.GITLAB_CONTAINER_REGISTRY }}/ogc_${{ env.ALGORITHM_NAME }}.${{ env.BRANCH }}:latest
labels: ${{ steps.meta.outputs.labels }}


2 changes: 1 addition & 1 deletion algorithm_configs/algorithm_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
algorithm_name: shah-get-dem-nasa-ogc
algorithm_version: nasa-ogc
repository_url: https://github.com/MAAP-Project/get-dem.git
docker_container_url: mas.dit.maap-project.org/root/maap-workspaces/base_images/dps:dps_base_image
docker_container_url: ghcr.io/maap-project/maap_base:main

# fill out these fields
# explain what this algorithm does
Expand Down
6 changes: 6 additions & 0 deletions docker/Dockerfile → docker/Dockerfile.algorithm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ FROM ${BASE_IMAGE_NAME}
USER root
WORKDIR /app

ARG REPO_URL_WITH_TOKEN
ARG REPO_NAME
ARG BRANCH
ARG BUILD_CMD

RUN git clone ${REPO_URL_WITH_TOKEN} && \
cd ${REPO_NAME} && \
git checkout ${BRANCH} && \
chmod -R 775 .

RUN bash ${BUILD_CMD} && conda clean -afy

CMD ["/bin/bash"]
13 changes: 13 additions & 0 deletions docker/Dockerfile.ogc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

FROM continuumio/miniconda3:23.10.0-1

USER root
WORKDIR /app

ARG PROCESS_CWL

RUN pip install pyyaml cwltool

COPY process_cwl/${PROCESS_CWL} /app/${PROCESS_CWL}

CMD ["/bin/bash"]
3 changes: 2 additions & 1 deletion generate_build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def generate_config(data):
:return
"""
try:
config_filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.txt")
config_filepath = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".env")
logging.debug("Writing build config file to {config_filepath}")
print(f"Writing config file at {config_filepath}")

Expand All @@ -38,6 +38,7 @@ def generate_config(data):
f.write(f"REPO_URL_WITH_TOKEN={data.get('repository_url')}\n")
f.write(f"REPO_NAME={repo_name}\n")
f.write(f"BRANCH={data.get('algorithm_version')}\n")
f.write(f"ALGORITHM_NAME={data.get('algorithm_name')}\n")
if data.get('build_command'):
f.write(f"BUILD_CMD={data.get('build_command')}\n")
print("Completed writing config file")
Expand Down
Binary file modified ogc_app_pack/__pycache__/ogc_app_pack.cpython-312.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion process.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $graph:
id: process
requirements:
DockerRequirement:
dockerPull: test
dockerPull: name:branch
baseCommand: /app/get-dem/nasa/run.sh
arguments: []
inputs:
Expand Down
2 changes: 1 addition & 1 deletion process_cwl/shah-get-dem-nasa-ogc.nasa-ogc.process.cwl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ $graph:
id: process
requirements:
DockerRequirement:
dockerPull: test
dockerPull: name:branch
baseCommand: /app/get-dem/nasa/run.sh
arguments: []
inputs:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ruamel.yaml
PyYAML

0 comments on commit e52cc08

Please sign in to comment.