-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
545 additions
and
291 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
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: Build containers | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
paths: | ||
- 'docker/*' | ||
- '.github/workflows/build-docker.yml' | ||
- 'src/**/*' | ||
- 'requirements*.txt' | ||
- 'pyproject.toml' | ||
- 'setup.py' | ||
- 'scripts/convert-requirements-to-conda-yml.py' | ||
|
||
concurrency: | ||
# make sure only one run of this workflow for a given PR or a given branch | ||
# can happen at one time. previous queued or started runs will be cancelled. | ||
# github.workflow is the workflow name | ||
# github.ref is the ref that triggered the workflow run | ||
# on push, this is refs/heads/<branch name> | ||
# on pull request, this is refs/pull/<pull request number>/merge | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
env: | ||
# Customize this name if needed. | ||
# The repo name is a very reasonable default! | ||
CONTAINER_NAME: invest | ||
|
||
jobs: | ||
build: | ||
name: Build containers | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create environment file | ||
run: | | ||
python scripts/convert-requirements-to-conda-yml.py requirements.txt > docker/environment.yml | ||
- name: Build docker | ||
run: | | ||
# Replace / (invalid tag character) with . | ||
SANITIZED_REF="$(echo ${{github.ref_name}} | sed 's|/|.|g')" | ||
cd docker && docker build \ | ||
--build-arg="INVEST_REPO=${{ github.repository }}" \ | ||
--build-arg="INVEST_VERSION=${{ github.sha }}" \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ github.sha }} \ | ||
-t ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${SANITIZED_REF} \ | ||
. | ||
- name: Test that GDAL and InVEST import | ||
run: | | ||
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest python -c "from osgeo import gdal" | ||
docker run --rm ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest python -m natcap.invest --version | ||
- name: Push docker | ||
if: github.event_name != 'pull_request' | ||
run: docker image push --all-tags ghcr.io/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }} |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
environment.yml |
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,26 @@ | ||
# syntax=docker/dockerfile:1 | ||
|
||
# Build the InVEST wheel in a separate container stage | ||
FROM debian:12.2 as build | ||
ARG INVEST_VERSION="main" | ||
ARG INVEST_REPO="natcap/invest" | ||
RUN apt update && apt install -y python3 python3-dev python3-pip python3-build build-essential git python3.11-venv | ||
RUN cd / && \ | ||
git clone https://github.com/${INVEST_REPO}.git && \ | ||
cd $(basename ${INVEST_REPO}) && \ | ||
git checkout ${INVEST_VERSION} && \ | ||
python3 -m build | ||
|
||
# Create the container for distribution that has runtime dependencies. | ||
FROM mambaorg/micromamba:1.5.0-bookworm-slim | ||
COPY --from=build /invest/dist/*.whl /tmp/ | ||
|
||
# The environment.yml file will be built during github actions. | ||
COPY --chown=$MAMBA_USER:$MAMBA_USER environment.yml /tmp/environment.yml | ||
RUN micromamba install -y -n base -c conda-forge -f /tmp/environment.yml && \ | ||
micromamba clean --all --yes && \ | ||
/opt/conda/bin/python -m pip install /tmp/*.whl && \ | ||
/opt/conda/bin/python -m pip cache purge && \ | ||
micromamba remove -y -n base cxx-compiler git | ||
|
||
ENTRYPOINT ["/usr/local/bin/_entrypoint.sh"] |
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
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
Oops, something went wrong.