Skip to content

Commit

Permalink
Merge pull request #1687 from Esri/jtroe/notebook-docker
Browse files Browse the repository at this point in the history
Add Notebook Docker Image and Build
  • Loading branch information
jtroe authored Oct 5, 2023
2 parents d58e462 + dbf893a commit be0bca1
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/DockerBuild.NotebookImage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: DockerBuild.NotebookImage

on:
# allow it to be run on-demand
workflow_dispatch:

jobs:
build-and-push:
name: Build Docker image and push to ghcr.io
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to Github Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/esri/arcgis-python-api-notebook
tags: |
type=raw,value=2.3.0,enable={{is_default_branch}}
type=raw,value=latest,enable={{is_default_branch}}
type=schedule,pattern={{date 'YY.MM'}},enable={{is_default_branch}}
type=sha,format=long
- id: docker_build
name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v4
with:
# relative path to the place where source code with Dockerfile is located
context: ./docker
file: ./docker/NotebookImage.Dockerfile
tags: ${{ steps.meta.outputs.tags }}
provenance: false
platforms: linux/amd64
push: true
42 changes: 42 additions & 0 deletions docker/NotebookImage.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ARG python_version="3.9"
FROM jupyter/base-notebook:python-${python_version}

ARG python_version
ARG arcgis_version="2.2.0"
ARG sampleslink="https://github.com/Esri/arcgis-python-api/releases/download/v${arcgis_version}/samples.zip"
ARG githubfolder="arcgis-python-api"
ENV DOCKER_STACKS_JUPYTER_CMD="notebook"

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

USER root

RUN apt-get update --yes && \
apt-get install --yes --no-install-recommends unzip && \
apt-get clean && rm -rf /var/lib/apt/lists/*

USER ${NB_UID}

# Install Python API from Conda
RUN conda install -c esri arcgis=${arcgis_version} -y \
&& conda clean --all -f -y \
&& find /opt/conda -name __pycache__ -type d -exec rm -rf {} +

# Fetch and extract samples from GitHub
RUN mkdir /home/${NB_USER}/$githubfolder && \
wget -O samples.zip $sampleslink \
&& unzip -q samples.zip -d /home/${NB_USER}/$githubfolder \
&& rm samples.zip \
&& mv /home/${NB_USER}/$githubfolder/* ./ \
&& rm -rf $githubfolder/ \
apidoc/ \
work/ \
talks/ \
environment.yml\
&& fix-permissions /home/${NB_USER}

RUN rm /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
COPY --chown=${NB_USER}:users jupyter_esri_logo.png /opt/conda/lib/python${python_version}/site-packages/notebook/static/base/images/logo.png
Binary file added docker/jupyter_esri_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit be0bca1

Please sign in to comment.