-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor cli building to speed up operational workflow, add compilati…
…on of fortran tools to the cli image build
- Loading branch information
1 parent
4bfd80a
commit a521d85
Showing
6 changed files
with
107 additions
and
36 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Build the base cli docker image | ||
|
||
# this workflow only gets executed when changes are pushed to Dockerfile.cli_base and environment.yml | ||
# i.e. the files which would impact the environment inside the cli base image | ||
# you can also optionally execute the image manually (in case you want to update to more recent packages) | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'Dockerfile.cli_base' | ||
- 'environment.yml' | ||
workflow_dispatch: # Allows the workflow to be triggered manually | ||
|
||
jobs: | ||
build_cli_base_image: | ||
uses: ./.github/workflows/build_images.yml # Path to your reusable workflow | ||
with: | ||
IMAGE_ID: cli_base | ||
|
||
build_cli_image: | ||
# update the cli since the base image has been updated too | ||
needs: [build_cli_base_image] | ||
uses: ./.github/workflows/build_images.yml # Path to your reusable workflow | ||
with: | ||
IMAGE_ID: cli |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Build the run docker image | ||
|
||
# this workflow only gets executed when changes are pushed to Dockerfile.run | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'Dockerfile.run' | ||
|
||
jobs: | ||
build_images: | ||
uses: ./.github/workflows/build_images.yml # Path to your reusable workflow | ||
with: | ||
IMAGE_ID: 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
# This Dockerfile provides instructions to build a docker image | ||
# which can be used to run the comman line interface - cli.py in the root of this repo | ||
# which is the command line interface - cli.py in the root of this repo | ||
# the cli allows us to call whatever python functions in this repo that we | ||
# need for our SOMISANA operations | ||
# | ||
# The docker image is built by .github/workflows/build_images.yml | ||
# The docker image is built by .github/workflows/build_cli_image.yml (which calles .github/workflows/build_images.yml) | ||
# which gets triggered whenever the operational workflow is run (either manually or as part of the scheduled workflow) | ||
# | ||
# This Dockerfile is based on the opendrift Dockerfile - See https://opendrift.github.io | ||
# We bake the somisana_croco environment into the image and use the cli.py as the entry point | ||
# | ||
# TODO: add a user and run the image as a user rather than as root? | ||
# All we do here is to over-write the code files inside the cli_base image, without having to recreate the environment. | ||
# We intentionally separate the cli_base image and this one, as the base image takes quite a lot of time to build | ||
# which gets annoying when testing new features of the operational workflow | ||
|
||
# FROM condaforge/mambaforge | ||
FROM condaforge/mambaforge:22.9.0-1 | ||
# build from the cli_base image | ||
FROM ghcr.io/saeon/somisana-croco_cli_base_main:latest | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN mkdir /somisana-croco | ||
# over-write the somisana-croco code | ||
WORKDIR /somisana-croco | ||
|
||
# Install somisana-croco environment into base conda environment | ||
COPY environment.yml . | ||
RUN mamba env update -n base -f environment.yml | ||
|
||
# Install somisana-croco | ||
ADD . /somisana-croco | ||
RUN pip install -e . | ||
|
||
# Set the cli.py as the entry point | ||
ENTRYPOINT ["python", "cli.py"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This Dockerfile provides instructions to build a docker image | ||
# which forms the base image for running the command line interface - cli.py in the root of this repo | ||
# the cli allows us to call whatever python functions in this repo that we | ||
# need for our SOMISANA operations | ||
# | ||
# The docker image is built as part of our operational workflow by | ||
# .github/workflows/build_cli_base_image.yml (which calles .github/workflows/build_images.yml) | ||
# and gets triggered whenever any changes are made toi the Dockerfile.cli_base or environment.yml files | ||
# i.e. the files needed to create the environment needed by the cli | ||
# | ||
# the .github/workflows/build_cli_image.yml is automatically run as part of the operational workflow | ||
# but all this does is to over-write the somisana-croco code in the image, to account for any code edits | ||
# which don't impact the environment. | ||
# We intentionally separate the two steps out, as the base image takes quite a lot of time to build | ||
# which gets annoying when testing new features of the operational workflow | ||
# | ||
# TODO: maybe add a user and run the image as a user rather than as root? | ||
|
||
# start with a mambaforge base image | ||
# We're fixing the mambaforge version due to dependency issues which get introduced if left open ended | ||
FROM condaforge/mambaforge:22.9.0-1 | ||
|
||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
# Install dependencies for compiling fortran tools | ||
RUN apt-get update && apt-get install -y \ | ||
make \ | ||
build-essential | ||
|
||
RUN mkdir /somisana-croco | ||
WORKDIR /somisana-croco | ||
|
||
# Install somisana-croco environment into base conda environment | ||
COPY environment.yml . | ||
RUN mamba env update -n base -f environment.yml | ||
|
||
# add the somisana-croco code and install into the base environment | ||
ADD . /somisana-croco | ||
RUN pip install -e . | ||
|
||
# Now compile the fortran tools | ||
WORKDIR /somisana-croco/crocotools_py/croco_pytools/prepro/Modules/tools_fort_routines/ | ||
RUN make clean | ||
RUN make |
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