Skip to content

Commit

Permalink
Merge pull request #65 from philvarner/pv/refactor-parameterize
Browse files Browse the repository at this point in the history
refactor parameterize
  • Loading branch information
vincentsarago committed Nov 28, 2023
2 parents 67d995c + 8c4e282 commit a967c8f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
43 changes: 24 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ on:
- '*'
pull_request:

env:
GDAL_VERSION: 3.8.0
GDAL_VERSION_TAG: 3.8

jobs:
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
strategy:
matrix:
gdal-version: [3.6]
steps:
- uses: actions/checkout@v4

Expand All @@ -35,23 +36,25 @@ jobs:
python -m pip install boto3 click
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to Github
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: .
load: true
file: dockerfiles/Dockerfile.gdal${{ matrix.gdal-version }}
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }}
file: dockerfiles/Dockerfile
build-args: |
GDAL_VERSION=${{ env.GDAL_VERSION }}
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max

Expand All @@ -61,7 +64,7 @@ jobs:
--platform=linux/amd64 \
--entrypoint bash \
-v ${{ github.workspace }}:/local \
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }} \
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }} \
/local/tests/tests.sh
deploy:
Expand Down Expand Up @@ -89,36 +92,38 @@ jobs:
aws-region: us-east-1

- name: Publish docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile.gdal${{ matrix.gdal-version }}
file: dockerfiles/Dockerfile
build-args: |
GDAL_VERSION=${{ env.GDAL_VERSION }}
push: true
cache-from: type=gha
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }}
tags: ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}

- name: Build and Deploy layers
run: |
docker run \
--platform=linux/amd64 \
--entrypoint bash \
-v ${{ github.workspace }}:/local \
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }} \
--rm ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }} \
/local/scripts/create-layer.sh
python scripts/deploy.py ${{ matrix.gdal-version }} --deploy
python scripts/deploy.py ${{ env.GDAL_VERSION }} --deploy
- name: Build Runtime and Push
run: |
runtimes='3.9 3.10 3.11'
for runtime in ${runtimes}; do
docker build \
--platform=linux/amd64 \
--build-arg GDAL_VERSION=${{ matrix.gdal-version }} \
--build-arg GDAL_VERSION=${{ env.GDAL_VERSION }} \
--build-arg RUNTIME_VERSION=${runtime} \
-f dockerfiles/runtimes/python \
-t ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }}-python${runtime} .
docker push ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ matrix.gdal-version }}-python${runtime}
-t ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${runtime} .
docker push ghcr.io/${{ github.repository_owner }}/lambda-gdal:${{ env.GDAL_VERSION_TAG }}-python${runtime}
done
update-layer:
Expand All @@ -135,7 +140,7 @@ jobs:
- uses: actions/setup-node@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -147,7 +152,7 @@ jobs:
python scripts/list.py | jq > layer.json
- name: Update resources
uses: test-room-7/action-update-file@v1
uses: test-room-7/action-update-file@v1.8.0
with:
file-path: layer.json
commit-msg: Update layer [skip ci]
Expand Down
6 changes: 4 additions & 2 deletions dockerfiles/Dockerfile.gdal3.6 → dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ RUN mkdir /tmp/netcdf \
# We use commit sha to make sure we are not using `cache` when building the docker image
# "7ca88116f5a46d429251361634eb24629f315076" is the latest commit on release/3.6 branch

# gdal

# GDAL
ARG GDAL_VERSION
RUN mkdir /tmp/gdal \
&& curl -sfL https://github.com/OSGeo/gdal/archive/7ca88116f5a46d429251361634eb24629f315076.tar.gz | tar zxf - -C /tmp/gdal --strip-components=1 \
&& curl -sfL https://github.com/OSGeo/gdal/archive/refs/tags/v${GDAL_VERSION}.tar.gz | tar zxf - -C /tmp/gdal --strip-components=1 \
&& cd /tmp/gdal \
&& mkdir build && cd build \
&& cmake3 .. \
Expand Down
8 changes: 5 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/bin/bash

GDAL_VERSION=$1
GDAL_VERSION_TAG=${GDAL_VERSION%.*}
RUNTIME=$2
RUNTIME_VERSION=$3

echo "Building image for AWS Lambda | GDAL: ${GDAL_VERSION} | Runtime: ${RUNTIME}:${RUNTIME_VERSION}"

docker buildx build \
--platform=linux/amd64 \
-f dockerfiles/Dockerfile.gdal${GDAL_VERSION} \
-t ghcr.io/lambgeo/lambda-gdal:${GDAL_VERSION} .
--build-arg GDAL_VERSION=${GDAL_VERSION} \
-f dockerfiles/Dockerfile \
-t ghcr.io/lambgeo/lambda-gdal:${GDAL_VERSION_TAG} .

docker buildx build \
--platform=linux/amd64 \
--build-arg GDAL_VERSION=${GDAL_VERSION} \
--build-arg RUNTIME_VERSION=${RUNTIME_VERSION} \
-f dockerfiles/runtimes/${RUNTIME} \
-t ghcr.io/lambgeo/lambda-gdal:${GDAL_VERSION}-${RUNTIME}${RUNTIME_VERSION} .
-t ghcr.io/lambgeo/lambda-gdal:${GDAL_VERSION_TAG}-${RUNTIME}${RUNTIME_VERSION} .

0 comments on commit a967c8f

Please sign in to comment.