Skip to content

Commit a2b6128

Browse files
committed
add LambdaBaseImage and minimal doc
1 parent c6e7726 commit a2b6128

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: DockerBuild.LambdaImage
2+
3+
on:
4+
# allow it to be run on-demand
5+
workflow_dispatch:
6+
7+
jobs:
8+
build-and-push:
9+
name: Build Docker image and push to ghcr.io
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Docker Buildx
17+
id: buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Login to Github Packages
21+
uses: docker/login-action@v2
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Docker meta
28+
id: meta
29+
uses: docker/metadata-action@v4
30+
with:
31+
images: |
32+
ghcr.io/esri/arcgis-python-api-lambda
33+
tags: |
34+
type=raw,value=2.1.0,enable={{is_default_branch}}
35+
type=raw,value=latest,enable={{is_default_branch}}
36+
type=schedule,pattern={{date 'YY.MM'}},enable={{is_default_branch}}
37+
type=sha,format=long
38+
39+
- id: docker_build
40+
name: Build image and push to GitHub Container Registry
41+
uses: docker/build-push-action@v4
42+
with:
43+
# relative path to the place where source code with Dockerfile is located
44+
context: .
45+
file: ./docker/LambdaBaseImage.Dockerfile
46+
tags: ${{ steps.meta.outputs.tags }}
47+
provenance: false
48+
platforms: linux/amd64
49+
push: true

docker/LambdaBaseImage.Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ARG PYTHON_VERSION=3.9
2+
# lambda python image, defaults to python 3.9
3+
FROM public.ecr.aws/lambda/python:${PYTHON_VERSION}
4+
5+
# set metadata
6+
LABEL org.opencontainers.image.authors="[email protected]"
7+
LABEL org.opencontainers.image.description="AWS Lambda image with arcgis Python API and its Linux dependencies preinstalled"
8+
LABEL org.opencontainers.image.licenses=Apache
9+
LABEL org.opencontainers.image.source=https://github.com/esri/arcgis-python-api
10+
11+
# install dependencies, then clean yum cache
12+
RUN yum -y install gcc krb5-devel krb5-server krb5-libs && yum clean all && rm -rf /var/cache/yum
13+
# install arcgis
14+
ARG ARCGIS_PYTHON_VERSION=2.1.0
15+
RUN pip3 install arcgis==${ARCGIS_PYTHON_VERSION} --target "${LAMBDA_TASK_ROOT}"
16+
# set entrypoint to app.py handler method
17+
# (note that app.py is missing from this base image)
18+
CMD [ "app.handler" ]
19+
# to use this base image, use FROM to specify its url
20+
# and `COPY app.py ${LAMBDA_TASK_ROOT}`
21+
# (copy your code into the lambda task root)

docker/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# docker
2+
3+
Some useful docker images for utilizing the ArcGIS API for Python in your workflows
4+
5+
## LambdaBaseImage
6+
7+
#### ghcr.io/esri/arcgis-python-api-lambda:latest
8+
9+
To use this image, setup your dockerfile like:
10+
```
11+
FROM ghcr.io/esri/arcgis-python-api-lambda
12+
COPY app.py ${LAMBDA_TASK_ROOT}
13+
```
14+
15+
your app.py should have a handler method:
16+
```
17+
import arcgis
18+
19+
def handler(event, context):
20+
"""
21+
AWS Lambda Handler
22+
"""
23+
print(f"Hello from AWS Lambda using ArcGIS API for Python {arcgis.__version__}!")
24+
```
25+
26+
Push to your _private_ AWS ECR instance, and configure lambda to run from this container image. As of this writing, public AWS ECR instances are not supported for lambda.

0 commit comments

Comments
 (0)