Skip to content

Commit 1acfed1

Browse files
committed
Merge 'upstream/master' into jy-update-html-df-item-2.3
2 parents cb2eed2 + 80e5e2d commit 1acfed1

File tree

183 files changed

+92092
-40971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+92092
-40971
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: DockerBuild.AzureFunctionsImage
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
# allow it to be run on-demand
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: "Version of ArcGIS API for Python to install in the image"
13+
type: string
14+
default: "2.3.1"
15+
python_version:
16+
description: "Python version to base image on"
17+
type: string
18+
default: "3.11"
19+
is_latest_release:
20+
description: "Version of ArcGIS API for Python is Latest current release"
21+
type: boolean
22+
default: false
23+
is_default_supported_python:
24+
description: "Python version is default supported version (i.e. python used by Pro and Enterprise)"
25+
type: boolean
26+
default: false
27+
28+
jobs:
29+
build-and-push:
30+
name: Build Docker image and push to ghcr.io
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Set up Docker Buildx
38+
id: buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Login to Github Packages
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ghcr.io
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Docker meta
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: |
53+
ghcr.io/esri/arcgis-python-api-azure-functions
54+
tags: |
55+
type=raw,value=${{ inputs.version }}-python${{ inputs.python_version }}
56+
type=raw,value=${{ inputs.version }},enable=${{ inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
57+
type=raw,value=latest,enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
58+
type=schedule,pattern={{date 'YY.MM'}},enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }}
59+
60+
- id: docker_build
61+
name: Build image and push to GitHub Container Registry
62+
uses: docker/build-push-action@v6
63+
with:
64+
# relative path to the place where source code with Dockerfile is located
65+
context: .
66+
file: ./docker/AzureFunctionsBaseImage.Dockerfile
67+
build-args: |
68+
python_version=${{ inputs.python_version }}
69+
arcgis_version=${{ inputs.version }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
provenance: false
72+
platforms: linux/amd64
73+
push: true

.github/workflows/DockerBuild.LambdaBaseImage.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
name: DockerBuild.LambdaImage
22

3+
permissions:
4+
contents: read
5+
packages: write
6+
37
on:
48
# allow it to be run on-demand
59
workflow_dispatch:
610
inputs:
711
version:
812
description: "Version of ArcGIS API for Python to install in the image"
913
type: string
10-
default: "2.3.0"
14+
default: "2.3.1"
1115
python_version:
1216
description: "Python version to base image on"
1317
type: string
@@ -28,22 +32,22 @@ jobs:
2832

2933
steps:
3034
- name: Checkout code
31-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3236

3337
- name: Set up Docker Buildx
3438
id: buildx
35-
uses: docker/setup-buildx-action@v2
39+
uses: docker/setup-buildx-action@v3
3640

3741
- name: Login to Github Packages
38-
uses: docker/login-action@v2
42+
uses: docker/login-action@v3
3943
with:
4044
registry: ghcr.io
4145
username: ${{ github.actor }}
4246
password: ${{ secrets.GITHUB_TOKEN }}
4347

4448
- name: Docker meta
4549
id: meta
46-
uses: docker/metadata-action@v4
50+
uses: docker/metadata-action@v5
4751
with:
4852
images: |
4953
ghcr.io/esri/arcgis-python-api-lambda
@@ -55,7 +59,7 @@ jobs:
5559
5660
- id: docker_build
5761
name: Build image and push to GitHub Container Registry
58-
uses: docker/build-push-action@v4
62+
uses: docker/build-push-action@v6
5963
with:
6064
# relative path to the place where source code with Dockerfile is located
6165
context: .

.github/workflows/DockerBuild.NotebookImage.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
name: DockerBuild.NotebookImage
22

3+
permissions:
4+
contents: read
5+
packages: write
6+
37
on:
48
# allow it to be run on-demand
59
workflow_dispatch:
610
inputs:
711
version:
812
description: "Version of ArcGIS API for Python to install in the image"
913
type: string
10-
default: "2.2.0"
14+
default: "2.3.1"
1115
python_version:
1216
description: "Python version to base image on"
1317
type: string
14-
default: "3.9"
18+
default: "3.11"
1519
is_latest_release:
1620
description: "Version of ArcGIS API for Python is Latest current release"
1721
type: boolean
@@ -32,18 +36,18 @@ jobs:
3236

3337
- name: Set up Docker Buildx
3438
id: buildx
35-
uses: docker/setup-buildx-action@v2
39+
uses: docker/setup-buildx-action@v3
3640

3741
- name: Login to Github Packages
38-
uses: docker/login-action@v2
42+
uses: docker/login-action@v3
3943
with:
4044
registry: ghcr.io
4145
username: ${{ github.actor }}
4246
password: ${{ secrets.GITHUB_TOKEN }}
4347

4448
- name: Docker meta
4549
id: meta
46-
uses: docker/metadata-action@v4
50+
uses: docker/metadata-action@v5
4751
with:
4852
images: |
4953
ghcr.io/esri/arcgis-python-api-notebook
@@ -55,7 +59,7 @@ jobs:
5559
5660
- id: docker_build
5761
name: Build image and push to GitHub Container Registry
58-
uses: docker/build-push-action@v4
62+
uses: docker/build-push-action@v6
5963
with:
6064
# relative path to the place where source code with Dockerfile is located
6165
context: ./docker
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
RUN pip3 install azure-functions && rm -rf /home/.cache/pip
14+
# install arcgis
15+
ARG arcgis_version="2.3.1"
16+
# adding .* ensures the latest patch version is installed
17+
RUN pip3 install "arcgis==${arcgis_version}.*" && rm -rf /home/.cache/pip

docker/LambdaBaseImage.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LABEL org.opencontainers.image.source=https://github.com/esri/arcgis-python-api
1111
# install dependencies, then clean yum cache
1212
RUN yum -y install gcc gcc-c++ krb5-devel krb5-server krb5-libs && yum clean all && rm -rf /var/cache/yum
1313
# install arcgis
14-
ARG arcgis_version="2.3.0"
14+
ARG arcgis_version="2.3.1"
1515
# adding .* ensures the latest patch version is installed
1616
RUN pip3 install "arcgis==${arcgis_version}.*" --target "${LAMBDA_TASK_ROOT}" && rm -rf /root/.cache/pip
1717
# set entrypoint to app.py handler method

docker/NotebookImage.Dockerfile

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1-
ARG python_version="3.9"
2-
FROM jupyter/base-notebook:python-${python_version}
1+
ARG python_version="3.11"
2+
FROM quay.io/jupyter/minimal-notebook:python-${python_version}
33

44
ARG python_version
5-
ARG arcgis_version="2.2.0"
5+
ARG arcgis_version="2.4.0"
66
ARG sampleslink="https://github.com/Esri/arcgis-python-api/releases/download/v${arcgis_version}/samples.zip"
77
ARG githubfolder="arcgis-python-api"
8-
ENV DOCKER_STACKS_JUPYTER_CMD="notebook"
8+
ARG env_name=arcgis
99

1010
LABEL org.opencontainers.image.authors="[email protected]"
11-
LABEL org.opencontainers.image.description="Jupyter Notebook with the latest version of the ArcGIS API for Python and its Linux dependencies preinstalled"
11+
LABEL org.opencontainers.image.description="Jupyter environment preconfigured for ArcGIS API for Python"
1212
LABEL org.opencontainers.image.licenses=Apache
1313
LABEL org.opencontainers.image.source=https://github.com/Esri/arcgis-python-api
1414

15-
USER root
16-
17-
RUN apt-get update --yes && \
18-
apt-get install --yes --no-install-recommends unzip && \
19-
apt-get clean && rm -rf /var/lib/apt/lists/*
20-
2115
USER ${NB_UID}
2216

2317
# Install Python API from Conda
24-
RUN conda install -c esri arcgis=${arcgis_version} -y \
18+
RUN conda create -n ${env_name} -c esri -c defaults arcgis=${arcgis_version} python=${python_version} -y --quiet --override-channels \
2519
&& conda clean --all -f -y \
2620
&& find /opt/conda -name __pycache__ -type d -exec rm -rf {} +
2721

22+
# Install arcgis-mapping if arcgis_version >= 2.4.0
23+
RUN (dpkg --compare-versions $arcgis_version ge 2.4.0 \
24+
&& conda install -n ${env_name} -c esri -c defaults arcgis-mapping -y --quiet --override-channels \
25+
&& conda clean --all -f -y \
26+
&& find /opt/conda -name __pycache__ -type d -exec rm -rf {} +;) \
27+
|| echo "[INFO] Skipped installing arcgis-mapping for version $arcgis_version (>= 2.4.0 required for arcgis-mapping)"
28+
2829
# Fetch and extract samples from GitHub
2930
RUN mkdir /home/${NB_USER}/$githubfolder && \
3031
wget -O samples.zip $sampleslink \
@@ -36,7 +37,34 @@ RUN mkdir /home/${NB_USER}/$githubfolder && \
3637
work/ \
3738
talks/ \
3839
environment.yml\
40+
# remove .DS_Store and __MACOSX from home directory:
41+
&& find /home/${NB_USER} -name ".DS_Store" -delete \
42+
&& rm -rf /home/${NB_USER}/__MACOSX \
3943
&& fix-permissions /home/${NB_USER}
4044

41-
RUN rm /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
42-
COPY --chown=${NB_USER}:users jupyter_esri_logo.png /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
45+
# See https://jupyter-docker-stacks.readthedocs.io/en/latest/using/recipes.html#add-a-custom-conda-environment-and-jupyter-kernel
46+
# Create Python kernel and link it to jupyter
47+
RUN "${CONDA_DIR}/envs/${env_name}/bin/python" -m ipykernel install --user --name="${env_name}" && \
48+
fix-permissions "${CONDA_DIR}" && \
49+
fix-permissions "/home/${NB_USER}"
50+
51+
52+
# More information here: https://github.com/jupyter/docker-stacks/pull/2047
53+
USER root
54+
55+
# Set DOCKER_STACKS_JUPYTER_CMD to "notebook" for versions less than 2.4.0
56+
RUN \
57+
(dpkg --compare-versions $arcgis_version lt 2.4.0 \
58+
&& echo 'DOCKER_STACKS_JUPYTER_CMD="notebook"' >> /etc/environment \
59+
&& echo "[INFO] Set DOCKER_STACKS_JUPYTER_CMD to notebook for arcgis < 2.4.0") \
60+
|| echo "[INFO] Using default DOCKER_STACKS_JUPYTER_CMD (lab) for arcgis >= 2.4.0"
61+
62+
RUN \
63+
# This changes a startup hook, which will activate the custom environment for the process
64+
echo conda activate "${env_name}" >> /usr/local/bin/before-notebook.d/10activate-conda-env.sh && \
65+
# This makes the custom environment default in Jupyter Terminals for all users which might be created later
66+
echo conda activate "${env_name}" >> /etc/skel/.bashrc && \
67+
# This makes the custom environment default in Jupyter Terminals for already existing NB_USER
68+
echo conda activate "${env_name}" >> "/home/${NB_USER}/.bashrc"
69+
70+
USER ${NB_UID}

docker/README.md

Lines changed: 37 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,39 @@ 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+
[Sample](samples/AzureFunctions)
33+
34+
To use this image, setup your dockerfile like
35+
```
36+
FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest
37+
COPY . /home/site/wwwroot
38+
```
39+
40+
Your copied resources will need to include:
41+
- `host.json`, with your appsettings
42+
- `function_app.py`, such as:
43+
44+
```
45+
import arcgis
46+
import azure.functions as func
47+
48+
app = func.FunctionApp()
49+
50+
@app.http_trigger(route='GET /', methods=['get'])
51+
def main(req: func.HttpRequest) -> func.HttpResponse:
52+
return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!")
53+
```
54+
55+
Push to the container registry of your choice.
56+
57+
For futher information, see:
58+
59+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#programming-model
60+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container-apps?tabs=acr%2Cbash&pivots=programming-language-python#create-and-test-the-local-functions-project
61+
- https://github.com/Azure/azure-functions-python-worker
62+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-custom-container
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local.settings.json
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
bin
2+
obj
3+
csx
4+
.vs
5+
edge
6+
Publish
7+
8+
*.user
9+
*.suo
10+
*.cscfg
11+
*.Cache
12+
project.lock.json
13+
14+
/packages
15+
/TestResults
16+
17+
/tools/NuGet.exe
18+
/App_Data
19+
/secrets
20+
/data
21+
.secrets
22+
appsettings.json
23+
local.settings.json
24+
25+
node_modules
26+
dist
27+
28+
# Local python packages
29+
.python_packages/
30+
31+
# Python Environments
32+
.env
33+
.venv
34+
env/
35+
venv/
36+
ENV/
37+
env.bak/
38+
venv.bak/
39+
40+
# Byte-compiled / optimized / DLL files
41+
__pycache__/
42+
*.py[cod]
43+
*$py.class
44+
45+
# Azurite artifacts
46+
__blobstorage__
47+
__queuestorage__
48+
__azurite_db*__.json

0 commit comments

Comments
 (0)