-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
69 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build/Publish Docker Hub Image | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Build/push image to Docker Hub | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
packages: write | ||
steps: | ||
|
||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Extract metadata for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ github.repository }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./environments/docker/Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
############################################################################## | ||
# OSMnx Dockerfile | ||
# License: MIT, see full license in LICENSE.txt | ||
# Web: https://osmnx.readthedocs.io | ||
############################################################################## | ||
|
||
FROM jupyter/base-notebook | ||
LABEL maintainer="Geoff Boeing <[email protected]>" | ||
LABEL url="https://osmnx.readthedocs.io" | ||
LABEL description="OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap." | ||
|
||
COPY --chmod=0755 requirements.txt /tmp | ||
# copy the package files needed for installation | ||
COPY --chmod=0755 ./environments/docker-test/requirements.txt ./osmnx/ | ||
COPY --chmod=0755 ./osmnx/ ./osmnx/osmnx/ | ||
COPY --chmod=0755 ./pyproject.toml ./osmnx/ | ||
COPY --chmod=0755 ./README.md ./osmnx/ | ||
|
||
# install packages in one RUN to keep image tidy | ||
# install and configuration everything in one RUN to keep image tidy | ||
RUN conda update --yes -c conda-forge --strict-channel-priority -n base mamba && \ | ||
mamba install --update-all --force-reinstall --yes -c conda-forge --strict-channel-priority --file /tmp/requirements.txt && \ | ||
rm -f -r -v /opt/conda/share/jupyter/kernels/python3 && \ | ||
mamba install --update-all --force-reinstall --yes -c conda-forge --strict-channel-priority --file ./osmnx/requirements.txt && \ | ||
python -m pip install --no-cache-dir -e ./osmnx/ && \ | ||
python -m ipykernel install --sys-prefix --name ox --display-name "Python (ox)" && \ | ||
rm -f -r -v /opt/conda/share/jupyter/kernels/python3 && \ | ||
python -m pip cache purge && \ | ||
conda clean --all --yes --quiet && \ | ||
conda info --all && \ | ||
conda list && \ | ||
jupyter kernelspec list && \ | ||
ipython -c "import osmnx; print('OSMnx version', osmnx.__version__)" | ||
|
||
# copy default jupyterlab settings, then set jupyter working directory to map to mounted volume | ||
COPY --chmod=0755 overrides.json /opt/conda/share/jupyter/lab/settings/ | ||
COPY --chmod=0755 ./environments/docker-test/overrides.json /opt/conda/share/jupyter/lab/settings/ | ||
WORKDIR /home/jovyan/work | ||
|
||
# set default command to launch when container is run | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,6 @@ | ||
#!/bin/bash | ||
DOCKERUSER=gboeing | ||
PACKAGE=osmnx | ||
|
||
# get the version number for the tag | ||
read -r -p "What is the $PACKAGE version number? " VERSION | ||
TAG="$DOCKERUSER/$PACKAGE:v$VERSION" | ||
ALLTAGS="$TAG" | ||
TAGARGS="-t $TAG" | ||
|
||
# optionally tag image with "latest" as well | ||
read -r -n 1 -p "Also tag this image \"latest\"? (y/n) " INPUT | ||
echo "" | ||
if [[ $INPUT == "Y" || $INPUT == "y" ]]; then | ||
ALLTAGS="$ALLTAGS $DOCKERUSER/$PACKAGE:latest" | ||
TAGARGS="$TAGARGS -t $DOCKERUSER/$PACKAGE:latest" | ||
fi | ||
|
||
# confirm then proceed | ||
echo "Image will be tagged \"$ALLTAGS\"" | ||
read -r -n 1 -p "Ready to proceed? (y/n) " INPUT | ||
echo "" | ||
if [[ $INPUT != "Y" && $INPUT != "y" ]]; then | ||
exit 1 | ||
fi | ||
|
||
# remove any existing containers or images | ||
docker stop $(docker ps -aq) | ||
docker rm $(docker ps -aq) | ||
docker rmi $(docker images -q) --force | ||
|
||
# login then multi-platform buildx the image and push it to the hub | ||
set -e | ||
docker login | ||
docker buildx build --no-cache --push --platform=linux/amd64,linux/arm64 $TAGARGS . | ||
|
||
# import package and print its version as a test, then export conda env to yml | ||
echo "Pushed $ALLTAGS to Docker Hub" | ||
echo "Testing image..." | ||
IMPORTED_VERSION=$(docker run --rm $TAG /bin/bash -c "ipython -c \"import $PACKAGE; print($PACKAGE.__version__)\"") | ||
echo "Imported $PACKAGE version $IMPORTED_VERSION, expected $VERSION" | ||
docker run --rm -v "$PWD":/home/jovyan/work $TAG /bin/bash -c "conda env export -n base > /home/jovyan/work/environment.yml" | ||
echo "Exported conda env to environment.yml" | ||
docker buildx build --no-cache --pull --load --platform=linux/arm64 -f environments/docker-test/Dockerfile -t gboeing/osmnx:test . | ||
IMPORTED_VERSION=$(docker run --rm gboeing/osmnx:test /bin/bash -c "ipython -c \"import osmnx; print(osmnx.__version__)\"") | ||
echo "Imported $IMPORTED_VERSION" |
Oops, something went wrong.