Skip to content
This repository was archived by the owner on Oct 21, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.zip
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM lambci/lambda:build-python3.6
FROM lambci/lambda:build-python3.7

ENV \
LANG=en_US.UTF-8 \
Expand All @@ -7,9 +7,13 @@ ENV \
RUN yum makecache fast
RUN yum install -y automake16 libpng-devel nasm

ENV PREFIX /var/task
# labda runtime: /var/task
# labda layer: /opt
ARG prefix=/var/task
ENV PREFIX=${prefix}

# versions of packages
# versions of packages, see also rasterio test matrix at:
# - https://github.com/mapbox/rasterio/blob/master/.travis.yml
ENV \
PKGCONFIG_VERSION=0.29.2 \
PROJ_VERSION=5.2.0 \
Expand Down Expand Up @@ -179,5 +183,9 @@ ENV \

ENV PATH=$PREFIX/bin:$PATH

RUN pip3 install pip -U
RUN pip3 install cython numpy --no-binary numpy
# numpy 1.17 requires an explicit c99 compiler option
# - https://github.com/numpy/numpy/pull/12783/files
ENV CFLAGS='-std=c99'
RUN pip3 install pip -U && \
pip3 install cython numpy "gdal==${GDAL_VERSION}" rasterio --no-binary :all:

57 changes: 42 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
SHELL = /bin/bash
TAG = 2.4.2
IMAGE := ${DOCKER_USERNAME}/amazonlinux-gdal:${TAG}
PY_VERSION = 3.7
GDAL_VERSION = 2.4.2
TAG = gdal${GDAL_VERSION}-py${PY_VERSION}
IMAGE := amazonlinux-gdal
BUILD := ${IMAGE}:${TAG}

all: build push

build:
docker build -f Dockerfile -t amazonlinux-gdal:${TAG} .
docker build -f Dockerfile -t ${BUILD} .

shell:
docker run --name amazonlinux --volume $(shell pwd)/:/data --rm -it ${IMAGE} /bin/bash
shell: build
docker run --name amazonlinux --volume $(shell pwd)/:/data --rm -it ${BUILD} /bin/bash

debug-gdal: build
docker run \
--name amazonlinux \
-itd amazonlinux-gdal:${TAG} /bin/bash
docker run --name amazonlinux \
-itd ${BUILD} /bin/bash
docker exec -it amazonlinux bash -c 'ldd /var/task/lib/libgdal.so'
docker exec -it amazonlinux bash -c 'readelf -d /var/task/lib/libgdal.so'
docker stop amazonlinux
docker rm amazonlinux

test:
docker run amazonlinux-gdal:${TAG} bash -c "gdalinfo --version | grep '${TAG}'"
docker run amazonlinux-gdal:${TAG} bash -c "gdalinfo --formats | grep 'JP2OpenJPEG'"
docker run ${BUILD} bash -c "gdalinfo --version | grep '${GDAL_VERSION}'"
docker run ${BUILD} bash -c "gdalinfo --formats | grep 'JP2OpenJPEG'"
docker run ${BUILD} bash -c "python --version | grep '${PY_VERSION}'"

push:
docker tag amazonlinux-gdal:${TAG} ${IMAGE}
docker push ${IMAGE}
docker push ${DOCKER_USERNAME}/${BUILD}

container-clean:
docker stop amazonlinux > /dev/null 2>&1 || true
docker rm amazonlinux > /dev/null 2>&1 || true

# ---
# lambda layer build and package using /opt

LAYER_BUILD = ${BUILD}-layer
LAYER_PACKAGE := amazonlinux-${TAG}-layer.zip

lambda-layer-build:
docker build -f Dockerfile -t ${LAYER_BUILD} --build-arg prefix=/opt .

lambda-layer-shell: lambda-layer-build container-clean
docker run --name amazonlinux --volume $(shell pwd)/:/data --rm -it ${LAYER_BUILD} /bin/bash

lambda-layer-package: lambda-layer-build container-clean
docker run --name amazonlinux -itd ${LAYER_BUILD} /bin/bash
docker exec -it amazonlinux bash -c 'mkdir -p $${PREFIX}/python/lib/python${PY_VERSION}/site-packages'
docker exec -it amazonlinux bash -c 'rsync -a /var/lang/lib/python${PY_VERSION}/site-packages/ $${PREFIX}/python/lib/python${PY_VERSION}/site-packages/'
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip python'
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip lib/*.so*'
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip lib64/*.so*'
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 --symlinks /tmp/package.zip bin'
docker exec -it amazonlinux bash -c 'cd $${PREFIX} && zip -r9 /tmp/package.zip share'
docker cp amazonlinux:/tmp/package.zip ${LAYER_PACKAGE}
docker stop amazonlinux && docker rm amazonlinux

clean:
docker stop amazonlinux
docker rm amazonlinux