diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ee4890..cd129e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -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: @@ -89,14 +92,16 @@ 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: | @@ -104,9 +109,9 @@ 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/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: | @@ -114,11 +119,11 @@ jobs: 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: @@ -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 }} @@ -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] diff --git a/dockerfiles/Dockerfile.gdal3.6 b/dockerfiles/Dockerfile similarity index 99% rename from dockerfiles/Dockerfile.gdal3.6 rename to dockerfiles/Dockerfile index ba3b55d..e4b9db6 100644 --- a/dockerfiles/Dockerfile.gdal3.6 +++ b/dockerfiles/Dockerfile @@ -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 .. \ diff --git a/scripts/build.sh b/scripts/build.sh index 61f9724..d8bf951 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,7 @@ #!/bin/bash GDAL_VERSION=$1 +GDAL_VERSION_TAG=${GDAL_VERSION%.*} RUNTIME=$2 RUNTIME_VERSION=$3 @@ -8,12 +9,13 @@ echo "Building image for AWS Lambda | GDAL: ${GDAL_VERSION} | Runtime: ${RUNTIME 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} .