Merge pull request #1955 from phargogh/bugfix/1952-container-builds-failing-to-find-libgdal
Defining the GDAL version used in the debian install.
This commit is contained in:
commit
df5a781e6b
|
@ -2,6 +2,7 @@ name: Build containers
|
|||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
paths:
|
||||
- 'docker/*'
|
||||
|
@ -39,6 +40,8 @@ jobs:
|
|||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
|
@ -55,9 +58,7 @@ jobs:
|
|||
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 }}" \
|
||||
docker build -f docker/Dockerfile \
|
||||
-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} \
|
||||
|
|
|
@ -1,26 +1,33 @@
|
|||
# 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"
|
||||
FROM debian:12.11 AS build
|
||||
RUN apt update && apt install -y python3 python3-dev python3-pip python3-build build-essential git python3.11-venv libgdal-dev
|
||||
RUN cd / && \
|
||||
git clone https://github.com/${INVEST_REPO}.git && \
|
||||
cd $(basename ${INVEST_REPO}) && \
|
||||
git checkout ${INVEST_VERSION} && \
|
||||
python3 -m build
|
||||
|
||||
# only copy in the files needed for building the wheel
|
||||
ADD src /invest/src
|
||||
ADD pyproject.toml /invest/pyproject.toml
|
||||
ADD setup.py /invest/setup.py
|
||||
ADD requirements.txt /invest/requirements.txt
|
||||
ADD .git /invest/.git
|
||||
RUN cd /invest && python3 -m build
|
||||
|
||||
# Create the container for distribution that has runtime dependencies.
|
||||
FROM mambaorg/micromamba:1.5.0-bookworm-slim
|
||||
FROM mambaorg/micromamba:2.1.1-debian12-slim
|
||||
# Python version should match the version used in stage 1.
|
||||
# If we update the stage 1 debian version, also update this python version
|
||||
ARG PYTHON_VERSION="3.11"
|
||||
COPY --from=build /invest/dist/*.whl /tmp/
|
||||
|
||||
|
||||
# Define this to be the GDAL version used to build the InVEST wheel in the debian step.
|
||||
# Check the debian package repo for the debian release above to confirm the version.
|
||||
# Debian's GDAL version will undoubtedly be earlier than what's available in conda-forge.
|
||||
ARG DEBIAN_GDAL_VERSION="3.6"
|
||||
|
||||
# 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 python==${PYTHON_VERSION} && \
|
||||
COPY --chown=$MAMBA_USER:$MAMBA_USER docker/environment.yml /tmp/environment.yml
|
||||
RUN micromamba install -y -n base -c conda-forge python==${PYTHON_VERSION} gdal=${DEBIAN_GDAL_VERSION} && \
|
||||
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 && \
|
||||
|
|
Loading…
Reference in New Issue