Skip to content

Commit 3f0607d

Browse files
committed
add Azure Functions dockerfile
1 parent 8800b43 commit 3f0607d

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: DockerBuild.AzureFunctionsImage
2+
3+
on:
4+
# allow it to be run on-demand
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "Version of ArcGIS API for Python to install in the image"
9+
type: string
10+
default: "2.3.1"
11+
python_version:
12+
description: "Python version to base image on"
13+
type: string
14+
default: "3.11"
15+
is_latest_release:
16+
description: "Version of ArcGIS API for Python is Latest current release"
17+
type: boolean
18+
default: false
19+
is_default_supported_python:
20+
description: "Python version is default supported version (i.e. python used by Pro and Enterprise)"
21+
type: boolean
22+
default: false
23+
24+
jobs:
25+
build-and-push:
26+
name: Build Docker image and push to ghcr.io
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Docker Buildx
34+
id: buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Login to Github Packages
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ghcr.io
41+
username: ${{ github.actor }}
42+
password: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Docker meta
45+
id: meta
46+
uses: docker/metadata-action@v5
47+
with:
48+
images: |
49+
ghcr.io/esri/arcgis-python-api-azure-functions
50+
tags: |
51+
type=raw,value=${{ inputs.version }}-python${{ inputs.python_version }}
52+
type=raw,value=${{ inputs.version }},enable=${{ inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
53+
type=raw,value=latest,enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
54+
type=schedule,pattern={{date 'YY.MM'}},enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
55+
56+
- id: docker_build
57+
name: Build image and push to GitHub Container Registry
58+
uses: docker/build-push-action@v6
59+
with:
60+
# relative path to the place where source code with Dockerfile is located
61+
context: .
62+
file: ./docker/AzureFunctionsBaseImage.Dockerfile
63+
build-args: |
64+
python_version=${{ inputs.python_version }}
65+
arcgis_version=${{ inputs.version }}
66+
tags: ${{ steps.meta.outputs.tags }}
67+
provenance: false
68+
platforms: linux/amd64
69+
push: true
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
ARG python_version=3.11
2+
# azure-functions python image, defaults to python 3.11
3+
FROM mcr.microsoft.com/azure-functions/python:4-python${python_version}
4+
5+
# set metadata
6+
LABEL org.opencontainers.image.authors="[email protected]"
7+
LABEL org.opencontainers.image.description="Azure Functions 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 apt-get update && apt-get install -y gcc libkrb5-dev krb5-config krb5-user && apt-get clean && rm -rf /var/lib/apt/lists/*
13+
# install arcgis
14+
ARG arcgis_version="2.3.1"
15+
# adding .* ensures the latest patch version is installed
16+
RUN pip3 install "arcgis==${arcgis_version}.*" && rm -rf /home/.cache/pip

docker/README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Some useful docker images for utilizing the ArcGIS API for Python in your workfl
88

99
To use this image, setup your dockerfile like:
1010
```
11-
FROM ghcr.io/esri/arcgis-python-api-lambda
11+
FROM ghcr.io/esri/arcgis-python-api-lambda:latest
1212
COPY app.py ${LAMBDA_TASK_ROOT}
1313
```
1414

@@ -24,3 +24,30 @@ def handler(event, context):
2424
```
2525

2626
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.
27+
28+
## AzureFunctionsBaseImage
29+
30+
#### ghcr.io/esri/arcgis-python-api-azure-functions:latest
31+
32+
To use this image, setup your dockerfile like
33+
```
34+
FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest
35+
COPY . /home/site/wwwroot
36+
```
37+
38+
Your copied resources will need to include:
39+
- `function.json`, such as https://github.com/Azure/azure-functions-docker-python-sample/blob/dev/HttpTrigger/function.json
40+
- `main.py`, such as:
41+
42+
```
43+
import arcgis
44+
import azure.functions as func
45+
46+
def main(req: func.HttpRequest) -> func.HttpResponse:
47+
return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!")
48+
```
49+
50+
For futher information, see:
51+
- https://github.com/Azure/azure-functions-python-worker
52+
- https://github.com/Azure/azure-functions-docker-python-sample
53+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-custom-container

0 commit comments

Comments
 (0)